facebook / facebook/flow

ES6 B.3.4: FunctionDeclaration in IfStatement parsed incorrectly

Offen
#4,512 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
parsing test262
Vorherrschende Sprache
Rust
Sterne
22.3k
Forks
1.9k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

[§ B.3.4](http://www.ecma-international.org/ecma-262/6.0/#sec-functiondeclarations-in-ifstatement-statement-clauses) allows `FunctionDeclaration` to appear in either branch of an `IfStatement` in non-strict mode. In strict mode, they are forbidden on both sides.

Flow incorrectly parses a function in an else branch as `FunctionExpression`.

```
if (false) function f() {} else function g() {}
^^^^^^^^^^^^^^^ FunctionDeclaration, good
^^^^^^^^^^^^^^^ FunctionExpression, wrong
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.