Commit 000ced33

000ced33b657Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

codegen: coerce args of a direct bound-method .call to the target's param types

A top-level/self Method object's .call emitted its args raw; under promote the target's params may be widened to poly, so an int arg no longer matches. Route each arg through emit_arg_or_default (which boxes into a poly param), like the ordinary call path. Unblocks method, i960.

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
000ced33b657
Parent
2fd99ec9f1c1

src/codegen_call.cmodifiedView file

@@ -3984,10 +3984,16 @@
39843984 int target = mn >= 0 ? method_obj_target_mi(c, mn) : -1;
39853985 int target_recvless = (mn >= 0 && nt_ref(nt, mn, "receiver") < 0);
39863986 if (target >= 0 && target_recvless) {
3987- /* top-level / self method: direct call sp_<name>(args). */
3987+ /* top-level / self method: direct call sp_<name>(args). Coerce each arg to
3988+ the target's parameter type (emit_arg_or_default boxes an int arg into a
3989+ poly param widened under promote, etc.). */
39883990 emit_method_cname(c, &c->scopes[target], b);
39893991 buf_puts(b, "(");
3990- for (int k = 0; k < argc; k++) { if (k) buf_puts(b, ", "); emit_expr(c, argv[k], b); }
3992+ for (int k = 0; k < argc; k++) {
3993+ if (k) buf_puts(b, ", ");
3994+ if (k < c->scopes[target].nparams) emit_arg_or_default(c, &c->scopes[target], k, argv[k], b);
3995+ else emit_expr(c, argv[k], b);
3996+ }
39913997 buf_puts(b, ")");
39923998 return;
39933999 }