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
Provenance
- Commit
4b84a6e- Tree
4b44c0d- Author
liviubobocu <liviu.bobocu@uipath.com>- Committer
GitHub <noreply@github.com>- Parent
668871b
2 files changed+17 added−16 removed
modified:src/locfile.c+3 added-2 removed
80 unmodified lines81 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 linesmodified:tests/jq.test+14 added-14 removed
115 unmodified lines116 {"a":1, "b":2, "a$2":4}117 118 %%FAIL119 {(0):1}120-jq: error: Cannot use number (0) as object key at <top-level>, line 1:120+jq: error: Cannot use number (0) as object key at <top-level>, line 1, column 2:121 122 %%FAIL123 {non_const:., (0):1}124-jq: error: Cannot use number (0) as object key at <top-level>, line 1:124+jq: error: Cannot use number (0) as object key at <top-level>, line 1, column 15:125 126 #127 # Field access, piping128 #170 unmodified lines299 [0,"hi!"]300 301 %%FAIL302 . as $foo | break $foo303-jq: error: $*label-foo is not defined at <top-level>, line 1:303+jq: error: $*label-foo is not defined at <top-level>, line 1, column 13:304 305 [.[]|[.,1]|until(.[0] < 1; [.[0] - 1, .[1] * .[0]])|.[1]]306 [1,2,3,4,5]307 [1,2,6,24,120]197 unmodified lines505 [0]506 507 %%FAIL IGNORE MSG508 . as [] | null509-jq: error: syntax error, unexpected ']', expecting '$' or '[' or '{' (Unix shell quoting issues?) at <top-level>, line 1:509+jq: error: syntax error, unexpected ']', expecting '$' or '[' or '{' (Unix shell quoting issues?) at <top-level>, line 1, column 7:510 511 %%FAIL IGNORE MSG512 . as {} | null513-jq: error: syntax error, unexpected '}' (Unix shell quoting issues?) at <top-level>, line 1:513+jq: error: syntax error, unexpected '}' (Unix shell quoting issues?) at <top-level>, line 1, column 7:514 515 # [.,(.[] | {x:.},.),.,.[]]516 517 #1231 unmodified lines1749 [2,3]1750 1751 %%FAIL1752 module (.+1); 01753-jq: error: Module metadata must be constant at <top-level>, line 1:1753+jq: error: Module metadata must be constant at <top-level>, line 1, column 1:1754 1755 %%FAIL1756 module []; 01757-jq: error: Module metadata must be an object at <top-level>, line 1:1757+jq: error: Module metadata must be an object at <top-level>, line 1, column 1:1758 1759 %%FAIL1760 include "a" (.+1); 01761-jq: error: Module metadata must be constant at <top-level>, line 1:1761+jq: error: Module metadata must be constant at <top-level>, line 1, column 1:1762 1763 %%FAIL1764 include "a" []; 01765-jq: error: Module metadata must be an object at <top-level>, line 1:1765+jq: error: Module metadata must be an object at <top-level>, line 1, column 1:1766 1767 %%FAIL1768 include "\ "; 01769-jq: error: Invalid escape at line 1, column 4 (while parsing '"\ "') at <top-level>, line 1:1769+jq: error: Invalid escape at line 1, column 4 (while parsing '"\ "') at <top-level>, line 1, column 10:1770 1771 %%FAIL1772 include "\(a)"; 01773-jq: error: Import path must be constant at <top-level>, line 1:1773+jq: error: Import path must be constant at <top-level>, line 1, column 9:1774 1775 modulemeta1776 "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 lines1785 21786 1787 %%FAIL IGNORE MSG1788 import "syntaxerror" as e; .1789-jq: error: syntax error, unexpected ';', expecting $end (Unix shell quoting issues?) at /home/nico/ws/jq/tests/modules/syntaxerror/syntaxerror.jq, line 1:1789+jq: error: syntax error, unexpected ';', expecting $end (Unix shell quoting issues?) at /home/nico/ws/jq/tests/modules/syntaxerror/syntaxerror.jq, line 1, column 8:1790 1791 %%FAIL IGNORE MSG1792 %::wat1793-jq: error: syntax error, unexpected '%', expecting $end (Unix shell quoting issues?) at <top-level>, line 1:1793+jq: error: syntax error, unexpected '%', expecting $end (Unix shell quoting issues?) at <top-level>, line 1, column 1:1794 1795 import "test_bind_order" as check; check::check1796 null1797 true72 unmodified lines1870 null1871 1872 %%FAIL IGNORE MSG1873 }1874-jq: error: syntax error, unexpected INVALID_CHARACTER, expecting $end (Unix shell quoting issues?) at <top-level>, line 1:1874+jq: error: syntax error, unexpected INVALID_CHARACTER, expecting $end (Unix shell quoting issues?) at <top-level>, line 1, column 1:1875 1876 (.[{}] = 0)?1877 null1878 451 unmodified lines