Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion acorn-loose/src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@ lp.initFunction = function(node) {
node.params = []
if (this.options.ecmaVersion >= 6) {
node.generator = false
node.expression = false
}
if (this.options.ecmaVersion >= 8)
node.async = false
Expand Down
12 changes: 7 additions & 5 deletions acorn/src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ pp.parsePropertyName = function(prop) {

pp.initFunction = function(node) {
node.id = null
if (this.options.ecmaVersion >= 6) node.generator = node.expression = false
if (this.options.ecmaVersion >= 6) node.generator = false
if (this.options.ecmaVersion >= 8) node.async = false
}

Expand Down Expand Up @@ -959,12 +959,14 @@ pp.parseArrowExpression = function(node, params, isAsync, forInit) {
// Parse function body and check parameters.

pp.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) {
let isExpression = isArrowFunction && this.type !== tt.braceL
let oldStrict = this.strict, useStrict = false

if (isExpression) {
if (isArrowFunction) {
node.expression = this.type !== tt.braceL
}

if (node.expression) {
node.body = this.parseMaybeAssign(forInit)
node.expression = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry if I'm wrong, but I think the expression property is required for ArrowFunctionExpression.

https://github.com/estree/estree/blob/master/es2015.md#arrowfunctionexpression

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Realized that after I open this, so I put this into draft. And opened an issue about it in ESTree estree/estree#323

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right ArrowFunctionExpression.expression is required.

this.checkParams(node, false)
} else {
let nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params)
Expand All @@ -988,10 +990,10 @@ pp.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) {
// Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
if (this.strict && node.id) this.checkLValSimple(node.id, BIND_OUTSIDE)
node.body = this.parseBlock(false, undefined, useStrict && !oldStrict)
node.expression = false
this.adaptDirectivePrologue(node.body.body)
this.labels = oldLabels
}

this.exitScope()
}

Expand Down
24 changes: 0 additions & 24 deletions test/tests-async-iteration.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ test("async function f() { for await (x of xs); }", {
"name": "f"
},
"generator": false,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -76,7 +75,6 @@ test("async function f() { for await (var x of xs); }", {
"name": "f"
},
"generator": false,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -143,7 +141,6 @@ test("async function f() { for await (let x of xs); }", {
"name": "f"
},
"generator": false,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -210,7 +207,6 @@ test("async function f() { for\nawait (x of xs); }", {
"name": "f"
},
"generator": false,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -273,7 +269,6 @@ test("f = async function() { for await (x of xs); }", {
"end": 45,
"id": null,
"generator": false,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -421,7 +416,6 @@ test("obj = { async f() { for await (x of xs); } }", {
"end": 42,
"id": null,
"generator": false,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -504,7 +498,6 @@ test("class A { async f() { for await (x of xs); } }", {
"end": 44,
"id": null,
"generator": false,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -676,7 +669,6 @@ test("async function* f() { await a; yield b; }", {
"name": "f"
},
"generator": true,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -759,7 +751,6 @@ test("f = async function*() { await a; yield b; }", {
"end": 43,
"id": null,
"generator": true,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -852,7 +843,6 @@ test("obj = { async* f() { await a; yield b; } }", {
"end": 40,
"id": null,
"generator": true,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -945,7 +935,6 @@ test("class A { async* f() { await a; yield b; } }", {
"end": 42,
"id": null,
"generator": true,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -1036,7 +1025,6 @@ test("class A { static async* f() { await a; yield b; } }", {
"end": 49,
"id": null,
"generator": true,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -1255,7 +1243,6 @@ test("var gen = { async *method() {} }", {
"end": 30,
"id": null,
"generator": true,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -1291,7 +1278,6 @@ test("export default async function*() {}", {
"end": 35,
"id": null,
"generator": true,
"expression": false,
"async": true,
"params": [],
"body": {
Expand Down Expand Up @@ -1366,7 +1352,6 @@ test("var C = class { async *method() {} }", {}, { "ecmaVersion": 9 })
// "end": 58,
// "id": null,
// "generator": true,
// "expression": false,
// "async": true,
// "params": [],
// "body": {
Expand Down Expand Up @@ -1455,7 +1440,6 @@ test("var C = class { async *method() {} }", {}, { "ecmaVersion": 9 })
// "end": 63,
// "id": null,
// "generator": true,
// "expression": false,
// "async": true,
// "params": [],
// "body": {
Expand Down Expand Up @@ -1571,7 +1555,6 @@ test("var C = class { async *method() {} }", {}, { "ecmaVersion": 9 })
// "end": 64,
// "id": null,
// "generator": true,
// "expression": false,
// "async": true,
// "params": [],
// "body": {
Expand Down Expand Up @@ -1601,7 +1584,6 @@ test("var C = class { async *method() {} }", {}, { "ecmaVersion": 9 })
// "end": 62,
// "id": null,
// "generator": false,
// "expression": false,
// "async": false,
// "params": [],
// "body": {
Expand Down Expand Up @@ -1660,7 +1642,6 @@ test("var C = class { async *method() {} }", {}, { "ecmaVersion": 9 })
// "end": 69,
// "id": null,
// "generator": true,
// "expression": false,
// "async": true,
// "params": [],
// "body": {
Expand Down Expand Up @@ -1690,7 +1671,6 @@ test("var C = class { async *method() {} }", {}, { "ecmaVersion": 9 })
// "end": 67,
// "id": null,
// "generator": false,
// "expression": false,
// "async": false,
// "params": [],
// "body": {
Expand Down Expand Up @@ -1776,7 +1756,6 @@ test("var C = class { async *method() {} }", {}, { "ecmaVersion": 9 })
// "end": 71,
// "id": null,
// "generator": true,
// "expression": false,
// "async": true,
// "params": [],
// "body": {
Expand Down Expand Up @@ -1823,7 +1802,6 @@ test("var C = class { async *method() {} }", {}, { "ecmaVersion": 9 })
// "end": 67,
// "id": null,
// "generator": false,
// "expression": false,
// "async": false,
// "params": [],
// "body": {
Expand Down Expand Up @@ -1887,7 +1865,6 @@ test("var C = class { async *method() {} }", {}, { "ecmaVersion": 9 })
// "end": 76,
// "id": null,
// "generator": true,
// "expression": false,
// "async": true,
// "params": [],
// "body": {
Expand Down Expand Up @@ -1934,7 +1911,6 @@ test("var C = class { async *method() {} }", {}, { "ecmaVersion": 9 })
// "end": 72,
// "id": null,
// "generator": false,
// "expression": false,
// "async": false,
// "params": [],
// "body": {
Expand Down
Loading