mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-08 08:44:37 +08:00
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.
20 lines
588 B
TypeScript
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(","));
|