1 parent
78045d8aa9
commit
a587ddc5a3
2 files changed
+15
-2
No files matched your search
+1
-2
@@ -78,8 +78,7 @@ void locfile_locate(struct locfile* l, location loc, const char* fmt, ...) {
|
||||
|
||||
int startline = locfile_get_line(l, loc.start);
|
||||
int offset = l->linemap[startline];
|
||||
int end = MIN(loc.end, l->linemap[startline+1] - 1);
|
||||
assert(end > loc.start);
|
||||
int end = MIN(loc.end, MAX(l->linemap[startline+1] - 1, loc.start + 1));
|
||||
jv underline = jv_string_repeat(jv_string("^"), end - loc.start);
|
||||
jv m2 = jv_string_fmt("%s at %s, line %d, column %d:\n %.*s\n %*s",
|
||||
jv_string_value(m1), jv_string_value(l->fname),
|
||||
|
||||
@@ -711,6 +711,20 @@ jq: 3 compile errors
|
||||
EOF
|
||||
diff $d/out $d/expected
|
||||
|
||||
# Test syntax error messages when error happens at the end.
|
||||
if $VALGRIND $Q $JQ -n 'if
|
||||
' > $d/out 2>&1; then
|
||||
echo 'syntax error not detected'
|
||||
exit 1
|
||||
fi
|
||||
cat > $d/expected <<EOF
|
||||
jq: error: syntax error, unexpected end of file at <top-level>, line 1, column 3:
|
||||
if
|
||||
^
|
||||
jq: 1 compile error
|
||||
EOF
|
||||
diff $d/out $d/expected
|
||||
|
||||
# Comments!
|
||||
if ! x=$($JQ -n '123 # comment') || [ "$x" != 123 ]; then
|
||||
echo 'comment did not work'
|
||||
|
||||
Reference in new issue
Block a user