Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
Fix issues with default object params in async functions (#96)
Browse files Browse the repository at this point in the history
This change allows async functions to have a spread argument which
defines a default value.
  • Loading branch information
danez authored and hzoo committed Aug 23, 2016
1 parent 4506822 commit 2cfae60
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ pp.parseCallExpressionArguments = function (close, possibleAsyncArrow) {
innerParenStart = this.state.start;
}

elts.push(this.parseExprListItem());
elts.push(this.parseExprListItem(undefined, possibleAsyncArrow ? { start: 0 } : undefined));
}

// we found an async arrow function so let's not allow any inner parens
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const b = async ({bar = "bar"}) => {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
{
"type": "File",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"program": {
"type": "Program",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 37
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "b"
},
"name": "b"
},
"init": {
"type": "ArrowFunctionExpression",
"start": 10,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 37
}
},
"id": null,
"generator": false,
"expression": false,
"async": true,
"params": [
{
"type": "ObjectPattern",
"start": 17,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 30
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 18,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 29
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 18,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 21
},
"identifierName": "bar"
},
"name": "bar"
},
"value": {
"type": "AssignmentPattern",
"start": 18,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 29
}
},
"left": {
"type": "Identifier",
"start": 18,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 21
},
"identifierName": "bar"
},
"name": "bar"
},
"right": {
"type": "StringLiteral",
"start": 24,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 29
}
},
"extra": {
"rawValue": "bar",
"raw": "\"bar\""
},
"value": "bar"
}
},
"extra": {
"shorthand": true
}
}
]
}
],
"body": {
"type": "BlockStatement",
"start": 35,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 35
},
"end": {
"line": 1,
"column": 37
}
},
"body": [],
"directives": []
}
}
}
],
"kind": "const"
}
],
"directives": []
}
}

0 comments on commit 2cfae60

Please sign in to comment.