Skip to content

Commit

Permalink
fix:added check for forXstatement pattern (#11703)
Browse files Browse the repository at this point in the history
  • Loading branch information
wlawt committed Jun 12, 2020
1 parent 3704728 commit 183acba
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
Expand Up @@ -329,6 +329,8 @@ const handle = {
return;
}

// for (MEMBER of ARR)
// for (MEMBER in ARR)
// { KEY: MEMBER } = OBJ -> { KEY: _destructureSet(MEMBER) } = OBJ
// { KEY: MEMBER = _VALUE } = OBJ -> { KEY: _destructureSet(MEMBER) = _VALUE } = OBJ
// {...MEMBER} -> {..._destructureSet(MEMBER)}
Expand All @@ -337,6 +339,9 @@ const handle = {
// [MEMBER = _VALUE] = ARR -> [_destructureSet(MEMBER) = _VALUE] = ARR
// [...MEMBER] -> [..._destructureSet(MEMBER)]
if (
// for (MEMBER of ARR)
// for (MEMBER in ARR)
parentPath.isForXStatement({ left: node }) ||
// { KEY: MEMBER } = OBJ
(parentPath.isObjectProperty({ value: node }) &&
parentPath.parentPath.isObjectPattern()) ||
Expand Down
@@ -0,0 +1,27 @@
class D {
#arr;
f() {
for (const el of this.#arr);
}
}

class C {
#p;
m() {
for (this.#p of []);
}
}

class E {
#arr;
f() {
for (this.#arr of [1, 2]);
}
}

class F {
#ar;
g() {
for (this.#ar in [1,2,3]);
}
}
@@ -0,0 +1,99 @@
var _arr = new WeakMap();

var D = /*#__PURE__*/function () {
"use strict";

function D() {
babelHelpers.classCallCheck(this, D);

_arr.set(this, {
writable: true,
value: void 0
});
}

babelHelpers.createClass(D, [{
key: "f",
value: function f() {
for (var el of babelHelpers.classPrivateFieldGet(this, _arr)) {
;
}
}
}]);
return D;
}();

var _p = new WeakMap();

var C = /*#__PURE__*/function () {
"use strict";

function C() {
babelHelpers.classCallCheck(this, C);

_p.set(this, {
writable: true,
value: void 0
});
}

babelHelpers.createClass(C, [{
key: "m",
value: function m() {
for (babelHelpers.classPrivateFieldDestructureSet(this, _p).value of []) {
;
}
}
}]);
return C;
}();

var _arr2 = new WeakMap();

var E = /*#__PURE__*/function () {
"use strict";

function E() {
babelHelpers.classCallCheck(this, E);

_arr2.set(this, {
writable: true,
value: void 0
});
}

babelHelpers.createClass(E, [{
key: "f",
value: function f() {
for (babelHelpers.classPrivateFieldDestructureSet(this, _arr2).value of [1, 2]) {
;
}
}
}]);
return E;
}();

var _ar = new WeakMap();

var F = /*#__PURE__*/function () {
"use strict";

function F() {
babelHelpers.classCallCheck(this, F);

_ar.set(this, {
writable: true,
value: void 0
});
}

babelHelpers.createClass(F, [{
key: "g",
value: function g() {
for (babelHelpers.classPrivateFieldDestructureSet(this, _ar).value in [1, 2, 3]) {
;
}
}
}]);
return F;
}();

0 comments on commit 183acba

Please sign in to comment.