facebook / facebook/flow

ES6 B.3.4: FunctionDeclaration in IfStatement parsed incorrectly

Open
#4,512 0 comments 0 reactions 0 assignees View on GitHub
parsing test262
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

[§ 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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.