facebook / facebook/flow

Parser recovers badly when function declaration is missing identifier

Aperta
#3,300 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
parsing
Lingua principale
Rust
Stelle
22.3k
Fork
1.9k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

`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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.