Skip to content

Commit

Permalink
fix: mark the last statement in do block as completion
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Mar 29, 2022
1 parent 1274a18 commit 1edb26e
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 1 deletion.
@@ -0,0 +1,9 @@
var result;
class C {
static #x;
static {
var x;
result = do { ({#x: x = 2} = C); }
}
}
expect(result).toBe(C);
@@ -0,0 +1,8 @@
var result;
class C {
static #x;
static {
var x;
result = do { ({#x: x = 2} = C); }
}
}
@@ -0,0 +1,10 @@
{
"plugins": [
"proposal-do-expressions",
"proposal-destructuring-private",
"proposal-class-static-block",
"proposal-class-properties",
"proposal-private-methods",
["proposal-object-rest-spread", { "useBuiltIns": true }]
]
}
@@ -0,0 +1,15 @@
var result;

class C {}

var _x = {
writable: true,
value: void 0
};

(() => {
var _m, _m2;

var x;
result = (_m = C, _m2 = babelHelpers.classStaticPrivateFieldSpecGet(_m, C, _x), x = _m2 === void 0 ? 2 : _m2, _m);
})();
@@ -0,0 +1,9 @@
var result;
class C {
static #x;
static {
var x;
result = do { ({#x: x = 2} = C); }
}
}
expect(result).toBe(C);
@@ -0,0 +1,8 @@
var result;
class C {
static #x;
static {
var x;
result = do { ({#x: x = 2} = C); }
}
}
@@ -0,0 +1,4 @@
{
"plugins": ["proposal-do-expressions", "proposal-destructuring-private"],
"minNodeVersion": "16.11.0"
}
@@ -0,0 +1,11 @@
var result;

class C {
static #x;
static {
var _m, _m2;

var x;
result = (_m = C, _m2 = _m.#x, x = _m2 === void 0 ? 2 : _m2, _m);
}
}
6 changes: 5 additions & 1 deletion packages/babel-traverse/src/path/introspection.ts
Expand Up @@ -149,7 +149,11 @@ export function isCompletionRecord(
if (Array.isArray(container) && path.key !== container.length - 1) {
return false;
}
} while ((path = path.parentPath) && !path.isProgram());
} while (
(path = path.parentPath) &&
!path.isProgram() &&
!path.isDoExpression()
);

return true;
}
Expand Down

0 comments on commit 1edb26e

Please sign in to comment.