Skip to content

Commit

Permalink
fix: unexpected asi generation with sequence expression
Browse files Browse the repository at this point in the history
  • Loading branch information
h-a-n-a committed Aug 21, 2024
1 parent f46a03c commit b8c03d4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/javascript/JavascriptParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3096,11 +3096,13 @@ class JavascriptParser extends Parser {
currentStatement.expression === expression)
) {
const old = /** @type {StatementPathItem} */ (this.statementPath.pop());
const prev = this.prevStatement;
for (const expr of expression.expressions) {
this.statementPath.push(expr);
this.walkExpression(expr);
this.statementPath.pop();
this.prevStatement = this.statementPath.pop();
}
this.prevStatement = prev;
this.statementPath.push(old);
} else {
this.walkExpressions(expression.expressions);
Expand Down
3 changes: 3 additions & 0 deletions test/cases/parsing/sequence-expression-asi/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const fn = (num) => {
return num;
};
21 changes: 21 additions & 0 deletions test/cases/parsing/sequence-expression-asi/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { fn } from "./a"

function d() {}

var num = 1
d(), fn();

export const b = 2
d(), fn();

export default (function Foo() {})
d(), fn();

export const c = 3
function foo() {
d(), fn();
}

it("should work", function() {
expect(fn(num)).toBe(1);
});

0 comments on commit b8c03d4

Please sign in to comment.