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

Add files/line/column to run errors like iteratorError? #256

Open
LeonB opened this issue Jun 18, 2024 · 5 comments
Open

Add files/line/column to run errors like iteratorError? #256

LeonB opened this issue Jun 18, 2024 · 5 comments

Comments

@LeonB
Copy link

LeonB commented Jun 18, 2024

Would it be feasible and wanted to add files/line/column to things like iterator errors?

I had something in mind like:

Error: Cannot iterate over null (null): test.jq:4
    4 |   | null | map({})
                   ^^^  Cannot iterate over null (null)
@LeonB
Copy link
Author

LeonB commented Sep 21, 2024

Looked into goyacc but I don't see an obvious way to pass the offset into Query/AST.

@wader
Copy link
Contributor

wader commented Sep 22, 2024

Hey! that would be nice. jq-lsp uses a modified version of gojq's parser to keep track of token positions, might be a start. To get positions for runtime errors i think you would also have to pass along things while compiling.

@LeonB
Copy link
Author

LeonB commented Sep 22, 2024

@wader thanks! I'll look into it.

@LeonB
Copy link
Author

LeonB commented Sep 22, 2024

gojq is executing bytecodes which I didn't know. Adding offset to every bytecode would be a bit much I expect, so I think something like a symbol table should be implemented where we link opcodes to the corresponding symbols and offsets. The codeinfo would be a nice start.

@wader do you have any thoughts about how to implement something like that?

@wader
Copy link
Contributor

wader commented Sep 23, 2024

No good ideas really, i would guess some kind of location info needs to be tracked on the stack during execution? maybe @itchyny has some ideas? looking at the codeinfo stuff atm it seems to be debug only, so maybe also needs to consider how much performance impact it would have

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants