Skip to content

Map/Set instances silently drop ordinary property assignment ([[Set]] no-ops) #447

Description

@dowdiness

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)));'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions