New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: validate rhs of in
when transpiling #p in C
#15133
Changes from all commits
15e991b
c562fe6
5bbe0a2
8b57ae0
a3ec863
5db231a
8bfbbd3
fea5241
a709b0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* @minVersion 7.20.1 */ | ||
|
||
export default function _checkInRHS(value) { | ||
if (Object(value) !== value) { | ||
throw TypeError( | ||
"right-hand side of 'in' should be an object, got " + | ||
(value !== null ? typeof value : "null") | ||
); | ||
} | ||
return value; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,8 @@ new (_x = /*#__PURE__*/new WeakMap(), _m = /*#__PURE__*/new WeakSet(), (_temp = | |
writable: true, | ||
value: void 0 | ||
}), babelHelpers.defineProperty(this, "x", void 0)), (() => { | ||
hasX = o => _x.has(o); | ||
hasM = o => _m.has(o); | ||
hasX = o => _x.has(babelHelpers.checkInRHS(o)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we move the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I lean to a new assumption
And we can implement the function checkInRHS(v) {
0 in v;
return v;
} so that the engine will do the checking job for us. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, we can't because |
||
hasM = o => _m.has(babelHelpers.checkInRHS(o)); | ||
})(), _initClass(); | ||
} | ||
}, (() => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
expect(() => class { static #p = #p in 0 }).toThrowError(`right-hand side of 'in' should be an object, got number`); | ||
expect(() => class { static #p = #p in "" }).toThrowError(`right-hand side of 'in' should be an object, got string`); | ||
expect(() => class { static #p = #p in true }).toThrowError(`right-hand side of 'in' should be an object, got boolean`); | ||
expect(() => class { static #p = #p in void 0 }).toThrowError(`right-hand side of 'in' should be an object, got undefined`); | ||
expect(() => class { static #p = #p in null }).toThrowError(`right-hand side of 'in' should be an object, got null`); | ||
expect(() => class { static #p = #p in Symbol.iterator }).toThrowError(`right-hand side of 'in' should be an object, got symbol`); | ||
expect(() => class { static #p = #p in 0n }).toThrowError(`right-hand side of 'in' should be an object, got bigint`); | ||
|
||
expect(() => class { static #p() {}; static q = #p in 0 }).toThrowError(`right-hand side of 'in' should be an object, got number`); | ||
expect(() => class { static #p() {}; static q = #p in "" }).toThrowError(`right-hand side of 'in' should be an object, got string`); | ||
expect(() => class { static #p() {}; static q = #p in true }).toThrowError(`right-hand side of 'in' should be an object, got boolean`); | ||
expect(() => class { static #p() {}; static q = #p in void 0 }).toThrowError(`right-hand side of 'in' should be an object, got undefined`); | ||
expect(() => class { static #p() {}; static q = #p in null }).toThrowError(`right-hand side of 'in' should be an object, got null`); | ||
expect(() => class { static #p() {}; static q = #p in Symbol.iterator }).toThrowError(`right-hand side of 'in' should be an object, got symbol`); | ||
expect(() => class { static #p() {}; static q = #p in 0n }).toThrowError(`right-hand side of 'in' should be an object, got bigint`); | ||
|
||
expect(() => new class { #p = #p in 0 }).toThrowError(`right-hand side of 'in' should be an object, got number`); | ||
expect(() => new class { #p = #p in "" }).toThrowError(`right-hand side of 'in' should be an object, got string`); | ||
expect(() => new class { #p = #p in true }).toThrowError(`right-hand side of 'in' should be an object, got boolean`); | ||
expect(() => new class { #p = #p in void 0 }).toThrowError(`right-hand side of 'in' should be an object, got undefined`); | ||
expect(() => new class { #p = #p in null }).toThrowError(`right-hand side of 'in' should be an object, got null`); | ||
expect(() => new class { #p = #p in Symbol.iterator }).toThrowError(`right-hand side of 'in' should be an object, got symbol`); | ||
expect(() => new class { #p = #p in 0n }).toThrowError(`right-hand side of 'in' should be an object, got bigint`); | ||
|
||
expect(() => new class { #p() {}; q = #p in 0 }).toThrowError(`right-hand side of 'in' should be an object, got number`); | ||
expect(() => new class { #p() {}; q = #p in "" }).toThrowError(`right-hand side of 'in' should be an object, got string`); | ||
expect(() => new class { #p() {}; q = #p in true }).toThrowError(`right-hand side of 'in' should be an object, got boolean`); | ||
expect(() => new class { #p() {}; q = #p in void 0 }).toThrowError(`right-hand side of 'in' should be an object, got undefined`); | ||
expect(() => new class { #p() {}; q = #p in null }).toThrowError(`right-hand side of 'in' should be an object, got null`); | ||
expect(() => new class { #p() {}; q = #p in Symbol.iterator }).toThrowError(`right-hand side of 'in' should be an object, got symbol`); | ||
expect(() => new class { #p() {}; q = #p in 0n }).toThrowError(`right-hand side of 'in' should be an object, got bigint`); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"minNodeVersion": "12.0.0" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parameter is added so that we don't have to deal with different interface across different
helper-create-class-features-plugin
version. In this future we will pass this parameter for theinRHSIsObject
assumption.