Parser recovers badly when function declaration is missing identifier
Open
parsing
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
`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.
Contributor guide
Assessment
This issue has not been assessed yet.