Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messages to show problematic position in the filter #3292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

itchyny
Copy link
Contributor

@itchyny itchyny commented Mar 10, 2025

This commit improves the parser and compiler error messages, making
it more easier to understand where in the filter the problem is.
Like modern compilers, jq will show the line in the filter where the
error occurred, will display squiggly line under the invalid token.

 $ ./jq -n '1 + 2 ( 3'    
jq: error: syntax error, unexpected '(', expecting end of file at <top-level>, line 1, column 7:
    1 + 2 ( 3
          ^
jq: 1 compile error

 $ ./jq -n '1 + $foo + 2'
jq: error: $foo is not defined at <top-level>, line 1, column 5:
    1 + $foo + 2
        ^^^^
jq: 1 compile error

This commit improves the parser and compiler error messages, making
it more easier to understand where in the filter the problem is.
Like modern compilers, jq will show the line in the filter where the
error occurred, will display squiggly line under the invalid token.
@itchyny itchyny force-pushed the improve-error-message-position branch from ba0089e to 467f441 Compare March 10, 2025 13:51
@itchyny itchyny added this to the 1.8 release milestone Mar 10, 2025
@itchyny itchyny force-pushed the improve-error-message-position branch 3 times, most recently from 180724a to 3c277a7 Compare March 11, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant