Open
Description
The following piece of code is valid but it is parsed incorrectly:
if (foo) { bar: 'baz' }
Here's a link to the TypeScript Playground showing that the snippet above is valid JavaScript or TypeScript:
https://www.typescriptlang.org/play?#code/JYMwBAFCD20JRgN5gEYEMBOAuMBydAXrmAL5A
The output of tree-sitter parse
is the following:
(program [0, 0] - [1, 0]
(if_statement [0, 0] - [0, 23]
condition: (parenthesized_expression [0, 3] - [0, 8]
(identifier [0, 4] - [0, 7]))
consequence: (expression_statement [0, 9] - [0, 23]
(object [0, 9] - [0, 23]
(pair [0, 11] - [0, 21]
key: (property_identifier [0, 11] - [0, 14])
value: (string [0, 16] - [0, 21]
(string_fragment [0, 17] - [0, 20])))))))
It looks like this should be parsing as a block with a labeled statement but it is parsing as an object literal