ganezdragon / tree-sitter-perl

a perl parser for javascript
MIT License
33 stars 9 forks source link

Parser hangs on `use open qw(:` with no newline at the end #21

Closed A-Walrus closed 1 year ago

A-Walrus commented 2 years ago

When trying to parse a file with the text use open qw(: and no newline at the end the parse hangs indefinitely.

asciinema recording showing the problem: https://asciinema.org/a/XX8rqGY1Npllp1BUM3X7i9vMc

Downstream issue: helix-editor/helix#4070

sshilovsky commented 2 years ago

Sometimes it hangs even with more file content below; but it's easier to reproduce with empty file

ganezdragon commented 1 year ago

it works with use open qw(:std :utf8);.

If I have it your way, perl says this

perl examples/test.pl 
Can't find string terminator ")" anywhere before EOF at examples/test.pl line 6.

So is use open qw(: a valid syntax?

A-Walrus commented 1 year ago

It is invalid syntax, but the issue is that the parser hangs indefinitely on it. The parser is going to run on code as it is being written, and shouldn't get stuck on invalid code. It should be returning a tree with error nodes.

ganezdragon commented 1 year ago

Got it. Pushed the fix in my latest commit. Will publish a new version sooner.