From 1a8a0ae0f55858a8f0a5e8c73f71e1e609b820f4 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Sun, 26 Feb 2017 00:25:09 -0600 Subject: [PATCH] Fix error message for undefined vars --- src/compile.c | 2 ++ tests/jq.test | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compile.c b/src/compile.c index 849e2f1..5b408e0 100644 --- a/src/compile.c +++ b/src/compile.c @@ -1007,6 +1007,8 @@ static int expand_call_arglist(block* b) { if (!curr->bound_by) { if (curr->symbol[0] == '*' && curr->symbol[1] >= '1' && curr->symbol[1] <= '3' && curr->symbol[2] == '\0') locfile_locate(curr->locfile, curr->source, "jq: error: break used outside labeled control structure"); + else if (curr->op == LOADV) + locfile_locate(curr->locfile, curr->source, "jq: error: $%s is not defined", curr->symbol); else locfile_locate(curr->locfile, curr->source, "jq: error: %s/%d is not defined", curr->symbol, block_count_actuals(curr->arglist)); errors++; diff --git a/tests/jq.test b/tests/jq.test index 47b842c..2c9cc88 100644 --- a/tests/jq.test +++ b/tests/jq.test @@ -278,7 +278,7 @@ null %%FAIL . as $foo | break $foo -jq: error: *label-foo/0 is not defined at , line 1: +jq: error: $*label-foo is not defined at , line 1: [.[]|[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]] [1,2,3,4,5] -- 2.40.0