]> granicus.if.org Git - jq/commitdiff
Fix error message for undefined vars
authorNicolas Williams <nico@cryptonector.com>
Sun, 26 Feb 2017 06:25:09 +0000 (00:25 -0600)
committerNicolas Williams <nico@cryptonector.com>
Sun, 26 Feb 2017 06:37:28 +0000 (00:37 -0600)
src/compile.c
tests/jq.test

index 849e2f1d2fbb5f0047d7b4b3bcdd74503917c4db..5b408e0d842409f653544b1ce7d93fa05601c7ac 100644 (file)
@@ -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++;
index 47b842c4437ecf04f52d708106554ae7e6b7b73a..2c9cc889ffbcf120868ec9483f2a8234d9460b3e 100644 (file)
@@ -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]