tree-sitter / tree-sitter-javascript

Javascript grammar for tree-sitter
MIT License
314 stars 108 forks source link

if (n-->0){} is parsed as JSX comment #287

Closed vird closed 3 months ago

vird commented 3 months ago

The following piece of code is valid but it is parsed incorrectly:

if (n-->0){}

Here's a link to the TypeScript Playground showing that the snippet above is valid JavaScript or TypeScript:

https://www.typescriptlang.org/play?#code/JYMwBAFAdgtDB8AGAlAbwL5A

The output of tree-sitter parse is the following:

> tree-sitter-javascript@0.20.1 parse
> tree-sitter parse 2.js

(program [0, 0] - [1, 0]
  (ERROR [0, 0] - [0, 5]
    (identifier [0, 4] - [0, 5]))
  (comment [0, 5] - [0, 12]))
2.js    0 ms    (ERROR [0, 0] - [0, 5])
amaanq commented 3 months ago

Thanks for your bug reports! These have been fixed now, let me know of other issues you run into