From 03d15b3ff083c077bfa9d0cbbb6e41d7ad5ca05c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Mon, 15 Mar 2021 01:16:18 +0100 Subject: [PATCH] :art: Improve lexer/parser/macros/strings --- ast | 2 +- src/parse/check.c | 5 +++-- tests/error/func_no_match.gw | 2 +- tests/pp/already_defined.gw | 2 +- tests/pp/call_too_many.gw | 2 +- tests/pp/undefined_macro.gw | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ast b/ast index 0bcba3a1..7d64efec 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 0bcba3a1156c0ca3c5af5488336e5fb092ac2cf8 +Subproject commit 7d64efec6200c89dd2e02dd5ee70ceacb1cea8a2 diff --git a/src/parse/check.c b/src/parse/check.c index ed9e1218..d2545a03 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -543,7 +543,7 @@ ANN static void print_arg(Arg_List e) { } ANN2(1) static void function_alternative(const Env env, const Type f, const Exp args, const loc_t pos){ - if(env->context->error) // needed for ufcs + if(env->context && env->context->error) // needed for ufcs return; gwerr_basic("Argument type mismatch", "call site", "valid alternatives:", env->name, pos, 0); @@ -728,7 +728,8 @@ ANN Type check_exp_call1(const Env env, Exp_Call *const exp) { exp->func->type = func->value_ref->type; return func->def->base->ret_type; } - function_alternative(env, exp->func->type, exp->args, exp->args->pos); + const loc_t pos = exp->args ? exp->args->pos : exp->func->pos; + function_alternative(env, exp->func->type, exp->args, pos); return NULL; } diff --git a/tests/error/func_no_match.gw b/tests/error/func_no_match.gw index 05961a5b..be3996f8 100644 --- a/tests/error/func_no_match.gw +++ b/tests/error/func_no_match.gw @@ -1,4 +1,4 @@ -#! [contains] argument type(s) do not match for fun +#! [contains] Argument type mismatch fun void test(){} fun void test(int i[], int j[]){} test(1,2); diff --git a/tests/pp/already_defined.gw b/tests/pp/already_defined.gw index 6af0964d..4dabbcf1 100644 --- a/tests/pp/already_defined.gw +++ b/tests/pp/already_defined.gw @@ -1,3 +1,3 @@ -#! [contains] macro already defined +#! [contains] Already defined #define macro #define macro diff --git a/tests/pp/call_too_many.gw b/tests/pp/call_too_many.gw index b133de5a..6c41b569 100644 --- a/tests/pp/call_too_many.gw +++ b/tests/pp/call_too_many.gw @@ -1,3 +1,3 @@ -#! [contains] too many arguments +#! [contains] Too many arguments #define macro(a) a <<< macro(1,2) >>>; diff --git a/tests/pp/undefined_macro.gw b/tests/pp/undefined_macro.gw index 5efd75d3..fbb69850 100644 --- a/tests/pp/undefined_macro.gw +++ b/tests/pp/undefined_macro.gw @@ -1,2 +1,2 @@ -#! [contains] undefined macro +#! [contains] Undefined #undef macro -- 2.43.0