Open overlookmotel opened 1 year ago
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.
set.add()
set.add
Set.prototype.add
Solution would be that if there are circular entries, apply prototype and any .add property after the set.add() calls.
.add
Same problem applies with WeakSet and with the .set() method of Maps and WeakMaps.
WeakSet
.set()
Map
WeakMap
Similar to #126.
Example 1:
Example 2:
In both cases,
set.add()
fails becauseset.add
is no longerSet.prototype.add
.Solution would be that if there are circular entries, apply prototype and any
.add
property after theset.add()
calls.Same problem applies with
WeakSet
and with the.set()
method ofMap
s andWeakMap
s.