Skip to content

Commit

Permalink
fix(babel-parser): Fix end of range of SequenceExpression (#13731)
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Sep 4, 2021
1 parent 0d5ca87 commit 62e42a3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
3 changes: 1 addition & 2 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -1735,8 +1735,7 @@ export default class ExpressionParser extends LValParser {
val.expressions = exprList;
// finish node at current location so it can pick up comments after `)`
this.finishNode(val, "SequenceExpression");
val.end = innerEndPos;
val.loc.end = innerEndLoc;
this.resetEndLocation(val, innerEndPos, innerEndLoc);
} else {
val = exprList[0];
}
Expand Down
@@ -1,3 +1,5 @@
var a = 1;

var b = a + 1;

(1, 2);
@@ -1,16 +1,16 @@
{
"type": "File",
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":14}},
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":7}},
"range": [
0,
26
35
],
"program": {
"type": "Program",
"start":0,"end":26,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":14}},
"start":0,"end":35,"loc":{"start":{"line":1,"column":0},"end":{"line":5,"column":7}},
"range": [
0,
26
35
],
"sourceType": "script",
"interpreter": null,
Expand Down Expand Up @@ -114,6 +114,54 @@
}
],
"kind": "var"
},
{
"type": "ExpressionStatement",
"start":28,"end":35,"loc":{"start":{"line":5,"column":0},"end":{"line":5,"column":7}},
"range": [
28,
35
],
"expression": {
"type": "SequenceExpression",
"start":29,"end":33,"loc":{"start":{"line":5,"column":1},"end":{"line":5,"column":5}},
"range": [
29,
33
],
"expressions": [
{
"type": "NumericLiteral",
"start":29,"end":30,"loc":{"start":{"line":5,"column":1},"end":{"line":5,"column":2}},
"range": [
29,
30
],
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
},
{
"type": "NumericLiteral",
"start":32,"end":33,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":5}},
"range": [
32,
33
],
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
],
"extra": {
"parenthesized": true,
"parenStart": 28
}
}
}
],
"directives": []
Expand Down

0 comments on commit 62e42a3

Please sign in to comment.