Page MenuHomePhorge

repro_jit_mixed_upvalues_return.cjs
No OneTemporary

Size
759 B
Referenced Files
None
Subscribers
None

repro_jit_mixed_upvalues_return.cjs

function factory(prefix) {
return function handle(n) {
let count = n + 1;
let state = { value: prefix + ':' + n };
let items = [prefix, n];
function trimPrefix(x) {
return x + ':' + items[0];
}
function next() {
return state.value + '|' + count + '|' + trimPrefix('ok');
}
return next;
};
}
const handle = factory('root');
for (let i = 0; i < 150; i++) {
const fn = handle(i);
if (fn() !== `root:${i}|${i + 1}|ok:root`) {
throw new Error(`warmup mismatch at ${i}: ${fn()}`);
}
}
const next = handle(7);
const got = next();
const want = 'root:7|8|ok:root';
if (got !== want) {
throw new Error(`expected ${want}, got ${got}`);
}
console.log('OK: mixed upvalue returned closure survived', got);

File Metadata

Mime Type
text/plain
Expires
Wed, Jun 17, 11:36 AM (23 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
569735
Default Alt Text
repro_jit_mixed_upvalues_return.cjs (759 B)

Event Timeline