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

Parser returns incorrect locations #3063

Open
ajor opened this issue Mar 15, 2024 · 4 comments
Open

Parser returns incorrect locations #3063

ajor opened this issue Mar 15, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@ajor
Copy link
Member

ajor commented Mar 15, 2024

After #2624, the parser appears to return incorrect locations for some AST nodes.

e.g.:

# bpftrace -e 'fn f($a : int64): str_t[16] { return $a; }'
stdin:1:33-42: ERROR: Function f is of type string[16], cannot return int64
fn f($a : int64): str_t[16] { return $a; }
                                ~~~~~~~~~
# bpftrace -e 'BEGIN { for ($v : @a) print(1) }'                        
stdin:1:24-29: ERROR: syntax error, unexpected call, expecting {
BEGIN { for ($v : @a) print(1) }
                       ~~~~~
@ajor ajor added the bug Something isn't working label Mar 15, 2024
@ajor
Copy link
Member Author

ajor commented Mar 15, 2024

cc @lenticularis39

@ajor
Copy link
Member Author

ajor commented Mar 15, 2024

It seems to be the "AFTER_COLON" state which is causing the problem:

yy_push_state(AFTER_COLON, yyscanner);

@ajor ajor self-assigned this Mar 15, 2024
@lenticularis39
Copy link
Contributor

Oops my lexer hacks are a bit broken.. hopefully just a little :D I'll have a look at it

@ajor
Copy link
Member Author

ajor commented Mar 15, 2024

I've got a possible fix here: ajor@113ffab. Not very familiar with flex though. Feel free to take this on if you fancy it, otherwise I'll continue some time next week.

All the tests I added today for error locations (#3064, #3065, #3066) have revealed some older problems too, which weren't caused by the user-defined functions PR, e.g.:
ajor@113ffab#diff-9537c973c4937d6eee4a927120e27d86a4f347f6d81caa5ca40e52745eb39f8aR297-R304

I'm wondering they're all related to us not restoring the location after calling unput().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants