Commit 361843a0

361843a0e73eMerged

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

Description

Fix yields=1 detection for methods with return, fix emit_method_call block arg

analyze.c: Don't mark a blk_param method yields=1 if it contains a ReturnNode. emit_inlined_call rejects inlining for such methods (scope_has_return=1), but the method was then skipped in emission (yields=1), causing undefined references.

codegen.c: emit_method_call now passes the block as sp_Proc * when the callee method has a blk_param and is not inlined (yields=0), matching emit_dispatch.

Co-Authored-By: Claude Sonnet 4.6 [email protected]

Details

Commit
361843a0e73e
Parent
6e1c13a7f0e2

src/analyze.cmodifiedView file

@@ -4605,7 +4605,17 @@
46054605 }
46064606 if (!ok) escapes = 1;
46074607 }
4608- if (!escapes && uses > 0) m->yields = 1;
4608+ if (!escapes && uses > 0) {
4609+ /* Don't mark yields=1 if the method has an explicit return: emit_inlined_call
4610+ would reject inlining anyway (scope_has_return), but the method would then
4611+ be skipped in emission because yields=1 -- causing undefined references. */
4612+ int has_ret = 0;
4613+ for (int id2 = 0; id2 < c->nt->count && !has_ret; id2++) {
4614+ const char *ty2 = nt_type(c->nt, id2);
4615+ if (ty2 && !strcmp(ty2, "ReturnNode") && comp_scope_of(c, id2) == m) has_ret = 1;
4616+ }
4617+ if (!has_ret) m->yields = 1;
4618+ }
46094619 }
46104620
46114621 /* intern every symbol literal so codegen can emit the id table */