Skip to content
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: mark some known globals or their functions as impure #4955

Merged
merged 10 commits into from Apr 30, 2023
2 changes: 1 addition & 1 deletion src/ast/nodes/shared/knownGlobals.ts
Expand Up @@ -164,7 +164,7 @@ const knownGlobals: GlobalDescription = {
isNaN: PF,
isPrototypeOf: O,
JSON: O,
Map: PC,
Map: C,
Math: {
__proto__: null,
[ValueProperties]: IMPURE,
Expand Down
4 changes: 4 additions & 0 deletions test/function/samples/tree-shake-map-constructor/_config.js
@@ -0,0 +1,4 @@
module.exports = {
description:
'Retain the Map constructor is called with the new keyword if the accepted param has side effects'
};
12 changes: 12 additions & 0 deletions test/function/samples/tree-shake-map-constructor/main.js
@@ -0,0 +1,12 @@
assert.ok(
TrickyPi marked this conversation as resolved.
Show resolved Hide resolved
new Map({
[Symbol.iterator]() {
return {
next() {
console.log('side effect');
return { done: true };
}
};
}
})
);