Skip to content

Commit

Permalink
fixed precedence of sequence expression in computed property name (#415)
Browse files Browse the repository at this point in the history
Co-authored-by: sanex3339 <yarabotayuvyandex3339>
  • Loading branch information
sanex3339 authored Jun 22, 2020
1 parent 177ec89 commit eee573b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion escodegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@
result.push('[');
}

result.push(this.generateExpression(expr, Precedence.Sequence, E_TTT));
result.push(this.generateExpression(expr, Precedence.Assignment, E_TTT));

if (computed) {
result.push(']');
Expand Down
12 changes: 12 additions & 0 deletions test/compare-acorn-es6/class-declaration.expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class ComputedKey {
[n1 + n2]() {
}
}
class AssignmentExpressionAsKey {
[n1 = n2]() {
}
}
class SequenceExpressionAsKey {
[(n1, n2)]() {
}
}
1 change: 1 addition & 0 deletions test/compare-acorn-es6/class-declaration.expected.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class ComputedKey{[n1+n2](){}}class AssignmentExpressionAsKey{[n1=n2](){}}class SequenceExpressionAsKey{[(n1,n2)](){}}
9 changes: 9 additions & 0 deletions test/compare-acorn-es6/class-declaration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class ComputedKey {
[n1 + n2]() {}
}
class AssignmentExpressionAsKey {
[n1 = n2]() {}
}
class SequenceExpressionAsKey {
[(n1, n2)]() {}
}

0 comments on commit eee573b

Please sign in to comment.