Discovered while implementing #444 (PR #445). Verified on main at f82e42b.
Assigning an ordinary (non-collection) property to a Map or Set instance via [[Set]] (obj.x = v) is silently dropped — the value does not read back, and it never appears in own keys:
var m = new Map();
m.extra = 1;
m.extra; // undefined (expected 1)
Reflect.ownKeys(m); // [] (expected ["extra"])
var s = new Set();
s.extra = 2;
s.extra; // undefined (expected 2)
Reflect.ownKeys(s); // [] (expected ["extra"])
Object.defineProperty(m, "extra", {...}) ([[DefineOwnProperty]]) works correctly and surfaces in Reflect.ownKeys/Object.getOwnPropertyNames, so the canonical Interpreter::own_property_keys reads bag correctly. The gap is in the [[Set]]/assignment path for Map/Set receivers, which does not write to bag.properties.
Real engines return the assigned value and include the key. Not a regression from #445 (pre-existing); out of scope there (different op — set_property, not ownKeys).
Repro
NEW_MOON_MOD=0 moon run cmd/main -- 'var m=new Map(); m.extra=1; console.log(m.extra, JSON.stringify(Reflect.ownKeys(m)));'
Discovered while implementing #444 (PR #445). Verified on
mainatf82e42b.Assigning an ordinary (non-collection) property to a
MaporSetinstance via[[Set]](obj.x = v) is silently dropped — the value does not read back, and it never appears in own keys:Object.defineProperty(m, "extra", {...})([[DefineOwnProperty]]) works correctly and surfaces inReflect.ownKeys/Object.getOwnPropertyNames, so the canonicalInterpreter::own_property_keysreadsbagcorrectly. The gap is in the[[Set]]/assignment path for Map/Set receivers, which does not write tobag.properties.Real engines return the assigned value and include the key. Not a regression from #445 (pre-existing); out of scope there (different op — set_property, not ownKeys).
Repro