Files
scriptc/tests/corpus/class-computed-key-descriptors.ts
T
Chris Tate aed7a20709 Let units without a record change the helpers they name in place
The serial mode's wave-end check threw when a unit changed a held function in place, even when the unit had no record and its change was its own lowering's: two functions that define computed-key properties on one class both rebuild the class's descriptor guard. Each unit's in-place changes are now checked against the names its IR and new entries quote: a unit with a record that changed such an entry has no record, and a unit without one keeps its changes. The wave-end check throws only for a change to an entry no unit names.
2026-10-27 09:03:39 -05:00

20 lines
588 B
TypeScript

// Two functions define computed-key properties on instances of one class.
class Point {
x = 1;
y = 2;
}
function defineValue(p: Point, key: string, value: number): void {
Object.defineProperty(p, key, { value, writable: true, enumerable: true, configurable: true });
}
function defineHidden(p: Point, key: string): void {
Object.defineProperty(p, key, { value: "hidden", writable: false, enumerable: false, configurable: true });
}
const p = new Point();
defineValue(p, "z", 3);
defineHidden(p, "label");
console.log(JSON.stringify(p));
console.log(Object.keys(p).join(","));