Summary
The ES2026 Set operation methods (union, intersection, difference, symmetricDifference, isSubsetOf, isSupersetOf, isDisjointFrom) currently only accept TGocciaSetValue instances as the other argument. Per ES2026 §7.3.45, they should accept any set-like object — an object with size, has(), and keys() — via the GetSetRecord(obj) abstract operation.
Current behavior
const setLike = {
size: 2,
has(v) { return v === 1 || v === 2; },
*keys() { yield 1; yield 2; }
};
new Set([1, 2, 3]).intersection(setLike);
// TypeError: Set.prototype.intersection: argument must be a Set
Expected behavior
new Set([1, 2, 3]).intersection(setLike);
// Set {1, 2}
What needs to happen
- Implement
GetSetRecord(obj) — read .size (coerce to number), .has (require callable), .keys (require callable) from the argument and return a record. Throw TypeError if validation fails.
- Replace the
is TGocciaSetValue argument checks in all 7 Set operation methods with a GetSetRecord call.
- Update the iteration in each method to use the keys iterator from the record instead of directly accessing
FItems.
References
Summary
The ES2026 Set operation methods (
union,intersection,difference,symmetricDifference,isSubsetOf,isSupersetOf,isDisjointFrom) currently only acceptTGocciaSetValueinstances as theotherargument. Per ES2026 §7.3.45, they should accept any set-like object — an object withsize,has(), andkeys()— via theGetSetRecord(obj)abstract operation.Current behavior
Expected behavior
What needs to happen
GetSetRecord(obj)— read.size(coerce to number),.has(require callable),.keys(require callable) from the argument and return a record. ThrowTypeErrorif validation fails.is TGocciaSetValueargument checks in all 7 Set operation methods with aGetSetRecordcall.FItems.References
GetSetRecord(obj)Set.prototype.union(other)step 4