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

Set, Map, WeakSet and WeakMap incorrect output where circular entries and prototype or some properties altered #521

Open
overlookmotel opened this issue Sep 29, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@overlookmotel
Copy link
Owner

Example 1:

// Input
const set = new Set();
set.add(set);
Object.setPrototypeOf(set, null);
export default set;
// Output
const set = Object.setPrototypeOf(new Set(), null);
set.add(set);
export default set;

Example 2:

// Input
const set = new Set();
set.add(set);
set.add = 123;
export default set;
// Output
const set = Object.assign(new Set(), {add: 123});
set.add(set);
export default set;

In both cases, set.add() fails because set.add is no longer Set.prototype.add.

Solution would be that if there are circular entries, apply prototype and any .add property after the set.add() calls.

Same problem applies with WeakSet and with the .set() method of Maps and WeakMaps.

@overlookmotel overlookmotel added the bug Something isn't working label Sep 29, 2023
@overlookmotel
Copy link
Owner Author

Similar to #126.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant