From 47e23274dc0fb78389e396fb41391ea089bcea66 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Tue, 26 Mar 2024 16:58:06 -0400 Subject: Better error message for missing parameters --- compiler.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/compiler.c b/compiler.c index 643fd35..2729484 100644 --- a/compiler.c +++ b/compiler.c @@ -4535,6 +4535,15 @@ Variable _eval_call(Scope *s, CompData *data, Vector *tokens, Function *f, Varia // create tmp var Variable set = scope_mk_stmp(s, data, cur); Variable from = _eval(s, data, tokens, pstart, pend); + + if (from.name == NULL) { + Token *p = vect_get(tokens, pstart); + printf("ERROR: Expected value for parameter \"%s\" in call to function \"%s\" (%d:%d)\n", cur->name, f->name, p->line, p->col); + p2_error = true; + i = f->inputs.count; + break; + } + // eval and set if (_var_ptr_type(&set) == PTYPE_REF) var_op_pure_set(data, &set, &from); @@ -4591,6 +4600,15 @@ Variable _eval_call(Scope *s, CompData *data, Vector *tokens, Function *f, Varia Variable set = scope_mk_stmp(s, data, cur); // eval and set Variable from = _eval(s, data, tokens, pstart, pend); + + if (from.name == NULL) { + Token *p = vect_get(tokens, pstart); + printf("ERROR: Expected value for parameter \"%s\" in call to function \"%s\" (%d:%d)\n", cur->name, f->name, p->line, p->col); + p2_error = true; + i = f->inputs.count; + break; + } + if (_var_ptr_type(&set) == PTYPE_REF) var_op_pure_set(data, &set, &from); else -- cgit v1.2.3