fix(babel-parser): Fix end of range of SequenceExpression (#13731)

This commit is contained in:
Sosuke Suzuki 2021-09-04 19:01:20 +09:00 committed by GitHub
parent 0d5ca876fd
commit 62e42a3f60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 6 deletions

View File

@ -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];
}

View File

@ -1,3 +1,5 @@
var a = 1;
var b = a + 1;
(1, 2);

View File

@ -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,
@ -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": []