Commit b2d6afa6

b2d6afa6251dMerged

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

Description

fix(codegen): explicit 0 return in compile_yield_inline_capture

compile_yield_inline_capture is a pure stmt helper (only emit() side effects). Without an explicit return at the end, Ruby's implicit return makes the function's tail value the result of whichever branch ran last — including compile_stmt(last_b) in the IfNode/CaseNode etc. arm. spinel's return-type inference then widens the function's return to the union of those, which trips -Wint-conversion on Windows MinGW (where compile_stmt returns mrb_int and the inferred function return type ended up as sp_StrArray *).

Add a trailing 0 so the function consistently returns mrb_int.

Linux gcc -O3 -Wno-all swallowed the warning; Windows didn't.

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

Details

Commit
b2d6afa6251d
Parent
874e02451105

spinel_codegen.rbmodifiedView file

@@ -38424,6 +38424,11 @@
3842438424 # the inverse), matching the coercion the expression-shaped branch
3842538425 # of compile_yield_call_expr already does.
3842638426 def compile_yield_inline_capture(yield_nid, blk, bp_names, map_from, map_to, result_tmp, rt_yc)
38427+ # Pure stmt helper (only emit() side effects, no value). Explicit
38428+ # `return 0` on every exit so spinel doesn't widen the function's
38429+ # inferred return type to the union of `compile_stmt`'s returns
38430+ # (which trips a -Wint-conversion on Windows when an if-branch's
38431+ # tail call to compile_stmt becomes the function's implicit return).
3842738432 args_id_yic = @nd_arguments[yield_nid]
3842838433 assigned_yic = 0
3842938434 if args_id_yic >= 0
@@ -38489,6 +38494,7 @@
3848938494 end
3849038495 end
3849138496 end
38497+ 0
3849238498 end
3849338499
3849438500 def compile_stmt_with_block(nid, blk, bp_names, map_from, map_to)