summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2017-02-26 00:25:09 -0600
committerNicolas Williams <nico@cryptonector.com>2017-02-26 00:37:28 -0600
commit1a8a0ae0f55858a8f0a5e8c73f71e1e609b820f4 (patch)
tree1573a56fa6e7ecfb38f7ec91711f88cb5807ea95
parent441b066dd8c3427b5bd9e71be2463841f28251af (diff)
Fix error message for undefined vars
-rw-r--r--src/compile.c2
-rw-r--r--tests/jq.test2
2 files changed, 3 insertions, 1 deletions
diff --git a/src/compile.c b/src/compile.c
index 849e2f1d..5b408e0d 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 47b842c4..2c9cc889 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 <top-level>, line 1:
+jq: error: $*label-foo is not defined at <top-level>, line 1:
[.[]|[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]]
[1,2,3,4,5]