Switch expression syntax should be recognized inside switch statements #52404
Labels
area-fe-analyzer-shared
Assigned by engineers; when triaging, prefer either area-front-end or area-analyzer.
fe-analyzer-shared-parser-recovery
Issues with the shared parser's handling of incorrect code
To the extent possible, it would be nice if the parser could recognize if the syntax of a switch expression is erroneously used where a switch statement is expected, e.g.:
Currently this produces the error
Expected to find 'case'
at the location of the0
, and then no further messages (because the parser gives up and skips to the end of the switch).It would be a lot nicer if the parser:
(1) would allow us to associate some documentation with the error message explaining how switch statements and switch expressions are disambiguated, and the analysis server could in principle even include some suggested fixups (e.g. convert to a switch expression by enclosing in parentheses). (2) would allow code completions and other analysis server features to continue working in spite of the error.
The text was updated successfully, but these errors were encountered: