-
-
Notifications
You must be signed in to change notification settings - Fork 10
fix: infinite loop parsing incomplete struct #66
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
base: main
Are you sure you want to change the base?
Conversation
The point of the error resilient parsing is to tolerate errors (accumulate them) but then continue parsing the rest of the file |
test/spitfire_test.exs
Outdated
| [ | ||
| {:__aliases__, [last: [line: 1, column: 2], line: 1, column: 2], [:Foo]}, | ||
| {:%{}, [closing: [line: 1, column: 8], line: 1, column: 6], [{:x, [line: 1, column: 8], nil}]} | ||
| ]}, [{[line: 1, column: 8], "missing closing brace for struct"}]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be expecting the error message to say something about missing an opening brace for the struct. There might be something else not going correct here. I don't think %Foo is valid syntax by itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in efafc6b in a way that also recovers from a bunch of other scenarios, and properly identifies wether the opening or closing braced for the right struct are missing
|
I tried integrating spitfire with elixir_sense and my custom error tolerant lexer (https://github.com/elixir-lsp/elixir_toxic) that returns valid token ranges for all tokens but I found spitfire too buggy. I created some property tests that generate elixir programs and there are just too many cases of spitfire misparsing valid code, crashing or looping that I didn't even started on error recovery. Long story short, I am working on another custom parser. |
Its not worth just fixing the bugs? |
|
Also, that repo is private |
797a37d to
efafc6b
Compare
Split from #65
Fixes
Spitfire.parse("%Foo = x")causing Spitfire to hangWith this fix the parser will continue while reporting an error. I'm not 100% sure if this is the behavior we want, we may want to fail the entire parsing, or report a different error.