Fix issue with unnamed args getting name flag

This commit is contained in:
Bruce Hill 2024-03-03 17:21:55 -05:00
parent c607b97732
commit 2eafa7a4da
2 changed files with 9 additions and 5 deletions

View File

@ -644,9 +644,9 @@ CORD compile(env_t *env, ast_t *ast)
// Pass 2: assign positional args
// Pass 3: compile and typecheck each arg
table_t arg_bindings = {};
for (arg_ast_t *arg = args; arg; arg = arg->next) {
if (arg->name)
Table_str_set(&arg_bindings, arg->name, arg->value);
for (arg_ast_t *call_arg = args; call_arg; call_arg = call_arg->next) {
if (call_arg->name)
Table_str_set(&arg_bindings, call_arg->name, call_arg->value);
}
for (arg_ast_t *call_arg = args; call_arg; call_arg = call_arg->next) {
if (call_arg->name)

View File

@ -1177,8 +1177,10 @@ ast_t *parse_method_call_suffix(parse_ctx_t *ctx, ast_t *self) {
const char *arg_start = pos;
const char *name = get_id(&pos);
whitespace(&pos);
if (!name || !match(&pos, "="))
if (!name || !match(&pos, "=")) {
name = NULL;
pos = arg_start;
}
ast_t *arg = optional(ctx, &pos, parse_expr);
if (!arg) {
@ -1214,8 +1216,10 @@ ast_t *parse_fncall_suffix(parse_ctx_t *ctx, ast_t *fn, bool is_extern) {
const char *arg_start = pos;
const char *name = get_id(&pos);
whitespace(&pos);
if (!name || !match(&pos, "="))
if (!name || !match(&pos, "=")) {
name = NULL;
pos = arg_start;
}
ast_t *arg = optional(ctx, &pos, parse_expr);
if (!arg) {