Commit 275f5e3b
275f5e3bee74Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
codegen: resolve instance_exec block params against their own block scope
The splice param-binding read each param's slot type from the instance_exec
call's scope. Block params are interned in their block's enclosing scope, so
for a forwarded block (instance_exec(args, &b) whose &b resolves to a literal
at a different call site) the call scope held an unrelated a, mis-reading
its type as poly and skipping the poly->int unbox of the bound arg. Resolve
the param from its own node's scope (correct for direct and forwarded blocks).
Fixes instance_exec_trampoline_result.
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 275f5e3bee74
- Parent
- 5ce5f881667b
src/codegen_call.cmodifiedView file
@@ -5371,7 +5371,11 @@
53715371
for (int p = 0; p < npar; p++) {53725372
const char *pn = nt_str(nt, reqs[p], "name");53735373
if (!pn) continue;5374-
LocalVar *plv = scope_local(comp_scope_of(c, id), pn);5374+
/* Resolve the param against its own block's scope (where block params5375+
are interned), not the call site's: for a forwarded block (`&b`5376+
resolved to the literal at a different site) the call scope holds a5377+
different `a`, mis-reading its slot type. */5378+
LocalVar *plv = scope_local(comp_scope_of(c, reqs[p]), pn);53755379
int ppoly = plv && plv->type == TY_POLY; /* widened slot needs a boxed rvalue */53765380
/* a scalar slot (e.g. an int block param, which is NOT widened) fed a53775381
poly arg needs the reverse: unbox the poly down to the slot type. */