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
# the inverse), matching the coercion the expression-shaped branch # of compile_yield_call_expr already does. def compile_yield_inline_capture(yield_nid, blk, bp_names, map_from, map_to, result_tmp, rt_yc) # Pure stmt helper (only emit() side effects, no value). Explicit # `return 0` on every exit so spinel doesn't widen the function's # inferred return type to the union of `compile_stmt`'s returns # (which trips a -Wint-conversion on Windows when an if-branch's # tail call to compile_stmt becomes the function's implicit return). args_id_yic = @nd_arguments[yield_nid] assigned_yic = 0 if args_id_yic >= 0 end end end 0 end def compile_stmt_with_block(nid, blk, bp_names, map_from, map_to)