Parser recovers badly when function declaration is missing identifier
Offen
parsing
- Vorherrschende Sprache
- Rust
- Sterne
- 22.3k
- Forks
- 1.9k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
`function () {}` (a statement, not an expression) errors with an "unexpected token (" because it's missing the function name. but it recovers by making an `Identifier` with name `(`, which is also illegal.
```
{
"type": "Identifier",
"name": "(",
"typeAnnotation": null,
"optional": false
}
```
maybe instead it should use an Identifier with name `""`. or, we allow `FunctionDeclaration` to have a null id for `export default function() {}`, so maybe it's slightly less invalid to use null instead of an invalid identifier.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.