🐛 Parser error with greater/less operators #1184
Labels
A-Parser
Area: parser
L-JavaScript
Language: JavaScript and super languages
S-Bug-confirmed
Status: report has been confirmed as a valid bug
S-Help-wanted
Status: you're familiar with the code base and want to help the project
Environment information
What happened?
While I was migrating our code base to biome, I came across a file where biome reported syntax errors. After taking a look, I found what is probably a bug in the parser (It was some legacy code that I fixed by now, which also got rid of the parser error.)
A simplified version of the code the shows the parser bug is:
This should be legal TypeScript code, but biome gives several parser errors.
When you replace
0 >= 1
with e.g.1
, the parser errors disappear. It also disappears when you remove the0 <
at the beginning or move it to the end (> 0
); or when you change<
to>
.You can see this in the playground with the latest version. It only happens when
TypeScript
is enabled, with our without JSX enabled. It might be related to type arguments in functions (e.g. microsoft/TypeScript#36662)https://biomejs.dev/playground/?unsafeParameterDecoratorsEnabled=false&allowComments=false&code=CgBmAHUAbgBjAHQAaQBvAG4AIABnAGUAdABEAGEAdABhAFMAbwB1AHIAYwBlAHMARgBvAHIAUABhAHIAYQBtAGUAdABlAHIAQwBvAHUAbgB0ACgAcgBhAG4AZwBlAHMAKQAgAHsACgAgACAAcgBlAHQAdQByAG4AIAAwACAAPAAgACQALgBnAHIAZQBwACgAcgBhAG4AZwBlAHMALAAgACgAcgBhAG4AZwBlACkAIAA9AD4AIAB7AHIAZQB0AHUAcgBuACAAMAAgAD4APQAgADEAOwB9ACkALgBsAGUAbgBnAHQAaAA7AAoAfQAKAA%3D%3D&jsx=false
An even simpler example:
The parser seems interpret as a literal
0
, followed by a type argument< (0 >
:Expected result
It should parse the code successfully.
Code of Conduct
The text was updated successfully, but these errors were encountered: