Generating correct assignments for live bindings updated with UpdateExpressions (#7489)
Fixes #7488
This commit is contained in:
parent
ab1e295c74
commit
c92e8be612
@ -29,8 +29,9 @@ const simpleAssignmentVisitor = {
|
||||
(path.parentPath.isExpressionStatement() && !path.isCompletionRecord())
|
||||
) {
|
||||
// ++i => (i += 1);
|
||||
const operator = path.node.operator == "++" ? "+=" : "-=";
|
||||
path.replaceWith(
|
||||
t.assignmentExpression("+=", arg.node, t.numericLiteral(1)),
|
||||
t.assignmentExpression(operator, arg.node, t.numericLiteral(1)),
|
||||
);
|
||||
} else {
|
||||
const varName = path.scope.generateDeclaredUidIdentifier("old").name;
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["external-helpers", ["transform-modules-commonjs"]]
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
export let diffLevel = 0;
|
||||
|
||||
export function diff() {
|
||||
if (!--diffLevel) {
|
||||
console.log("hey");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true,
|
||||
});
|
||||
exports.diff = diff;
|
||||
exports.diffLevel = void 0;
|
||||
let diffLevel = 0;
|
||||
exports.diffLevel = diffLevel;
|
||||
|
||||
function diff() {
|
||||
if (!(exports.diffLevel = diffLevel = diffLevel - 1)) {
|
||||
console.log("hey");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
export let diffLevel = 0;
|
||||
|
||||
export function diff() {
|
||||
if (!++diffLevel) {
|
||||
console.log("hey");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true,
|
||||
});
|
||||
exports.diff = diff;
|
||||
exports.diffLevel = void 0;
|
||||
let diffLevel = 0;
|
||||
exports.diffLevel = diffLevel;
|
||||
|
||||
function diff() {
|
||||
if (!(exports.diffLevel = diffLevel = diffLevel + 1)) {
|
||||
console.log("hey");
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user