Skip to content
Myr

Include column number in parser and compiler error messages (#3257)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Resolves #1027, resolves #2334, and resolves #3256.

authored by liviubobocu · committed by GitHub · parent 668871b · Browse files · 2 files+17 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+17 added−16 removed

  • tests:+14 added−14 removed
  • other:+3 added−2 removed

2 files+17 added−16 removed

modified:src/locfile.c+3 added-2 removed
80 unmodified lines
81 jq_report_error(l->jq, jv_string_fmt("jq: error: %s\n<unknown location>", jv_string_value(m1)));82 jv_free(m1);83 return;84 }85 jv m2 = jv_string_fmt("%s at %s, line %d:\n%.*s%*s", jv_string_value(m1),86 jv_string_value(l->fname), startline + 1,85 jv m2 = jv_string_fmt("%s at %s, line %d, column %d:\n%.*s%*s",86 jv_string_value(m1), jv_string_value(l->fname),87 startline + 1, loc.start - offset + 1,88 locfile_line_length(l, startline), l->data + offset,89 loc.start - offset, "");90 jv_free(m1);91 jq_report_error(l->jq, m2);
2 unmodified lines
modified:tests/jq.test+14 added-14 removed
115 unmodified lines
116{"a":1, "b":2, "a$2":4}117118%%FAIL119{(0):1}120jq: error: Cannot use number (0) as object key at <top-level>, line 1:120jq: error: Cannot use number (0) as object key at <top-level>, line 1, column 2:121122%%FAIL123{non_const:., (0):1}124jq: error: Cannot use number (0) as object key at <top-level>, line 1:124jq: error: Cannot use number (0) as object key at <top-level>, line 1, column 15:125126#127# Field access, piping128#
170 unmodified lines
299[0,"hi!"]300301%%FAIL302. as $foo | break $foo303jq: error: $*label-foo is not defined at <top-level>, line 1:303jq: error: $*label-foo is not defined at <top-level>, line 1, column 13:304305[.[]|[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]]306[1,2,3,4,5]307[1,2,6,24,120]
197 unmodified lines
505[0]506507%%FAIL IGNORE MSG508. as [] | null509jq: error: syntax error, unexpected ']', expecting '$' or '[' or '{' (Unix shell quoting issues?) at <top-level>, line 1:509jq: error: syntax error, unexpected ']', expecting '$' or '[' or '{' (Unix shell quoting issues?) at <top-level>, line 1, column 7:510511%%FAIL IGNORE MSG512. as {} | null513jq: error: syntax error, unexpected '}' (Unix shell quoting issues?) at <top-level>, line 1:513jq: error: syntax error, unexpected '}' (Unix shell quoting issues?) at <top-level>, line 1, column 7:514515# [.,(.[] | {x:.},.),.,.[]]516517#
1231 unmodified lines
1749[2,3]17501751%%FAIL1752module (.+1); 01753jq: error: Module metadata must be constant at <top-level>, line 1:1753jq: error: Module metadata must be constant at <top-level>, line 1, column 1:17541755%%FAIL1756module []; 01757jq: error: Module metadata must be an object at <top-level>, line 1:1757jq: error: Module metadata must be an object at <top-level>, line 1, column 1:17581759%%FAIL1760include "a" (.+1); 01761jq: error: Module metadata must be constant at <top-level>, line 1:1761jq: error: Module metadata must be constant at <top-level>, line 1, column 1:17621763%%FAIL1764include "a" []; 01765jq: error: Module metadata must be an object at <top-level>, line 1:1765jq: error: Module metadata must be an object at <top-level>, line 1, column 1:17661767%%FAIL1768include "\ "; 01769jq: error: Invalid escape at line 1, column 4 (while parsing '"\ "') at <top-level>, line 1:1769jq: error: Invalid escape at line 1, column 4 (while parsing '"\ "') at <top-level>, line 1, column 10:17701771%%FAIL1772include "\(a)"; 01773jq: error: Import path must be constant at <top-level>, line 1:1773jq: error: Import path must be constant at <top-level>, line 1, column 9:17741775modulemeta1776"c"1777{"whatever":null,"deps":[{"as":"foo","is_data":false,"relpath":"a"},{"search":"./","as":"d","is_data":false,"relpath":"d"},{"search":"./","as":"d2","is_data":false,"relpath":"d"},{"search":"./../lib/jq","as":"e","is_data":false,"relpath":"e"},{"search":"./../lib/jq","as":"f","is_data":false,"relpath":"f"},{"as":"d","is_data":true,"relpath":"data"}],"defs":["a/0","c/0"]}
7 unmodified lines
1785217861787%%FAIL IGNORE MSG1788import "syntaxerror" as e; .1789jq: error: syntax error, unexpected ';', expecting $end (Unix shell quoting issues?) at /home/nico/ws/jq/tests/modules/syntaxerror/syntaxerror.jq, line 1:1789jq: error: syntax error, unexpected ';', expecting $end (Unix shell quoting issues?) at /home/nico/ws/jq/tests/modules/syntaxerror/syntaxerror.jq, line 1, column 8:17901791%%FAIL IGNORE MSG1792%::wat1793jq: error: syntax error, unexpected '%', expecting $end (Unix shell quoting issues?) at <top-level>, line 1:1793jq: error: syntax error, unexpected '%', expecting $end (Unix shell quoting issues?) at <top-level>, line 1, column 1:17941795import "test_bind_order" as check; check::check1796null1797true
72 unmodified lines
1870null18711872%%FAIL IGNORE MSG1873}1874jq: error: syntax error, unexpected INVALID_CHARACTER, expecting $end (Unix shell quoting issues?) at <top-level>, line 1:1874jq: error: syntax error, unexpected INVALID_CHARACTER, expecting $end (Unix shell quoting issues?) at <top-level>, line 1, column 1:18751876(.[{}] = 0)?1877null1878
451 unmodified lines