Skip to content

Commit

Permalink
Fix bound catchExprs
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohnson committed Oct 25, 2017
1 parent 5a298ea commit d33d831
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugins/catchExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function(parser) {
this.state.inMatchCaseTest = true;

this.parseCatchCaseAtoms(node);
if (this.isContextual("as")) {
if (this.eatContextual("as")) {
this.parseCatchCaseBinding(node);
}

Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/catch-expression/binding/basic/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a
catch Error as err: err
166 changes: 166 additions & 0 deletions test/fixtures/catch-expression/binding/basic/expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"type": "File",
"start": 0,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 25
}
},
"program": {
"type": "Program",
"start": 0,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 25
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 25
}
},
"expression": {
"type": "CatchExpression",
"start": 0,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 25
}
},
"expression": {
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "a"
},
"name": "a"
},
"cases": [
{
"type": "CatchCase",
"start": 4,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 25
}
},
"atoms": [
{
"type": "Identifier",
"start": 10,
"end": 15,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 13
},
"identifierName": "Error"
},
"name": "Error"
}
],
"binding": {
"type": "Identifier",
"start": 19,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 17
},
"end": {
"line": 2,
"column": 20
},
"identifierName": "err"
},
"name": "err"
},
"consequent": {
"type": "ExpressionStatement",
"start": 24,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 22
},
"end": {
"line": 2,
"column": 25
}
},
"expression": {
"type": "Identifier",
"start": 24,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 22
},
"end": {
"line": 2,
"column": 25
},
"identifierName": "err"
},
"name": "err"
}
}
}
]
}
}
],
"directives": []
}
}

0 comments on commit d33d831

Please sign in to comment.