Commit a9123df6
a9123df66e21Merged
Yusuke Endoh <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified
Description
fix(codegen): scope class-body bare-call return inference to no-recv
`infer_call_type` had a fallback at the end that used `cls_method_return(@current_class_idx, mname)` whenever `@current_class_idx` was set, regardless of whether the call actually had a receiver. `Fiber.yield true` inside a class body would hit this branch first, find no "yield" method on the enclosing class, fall back to the default "int", and the `mname == "yield" && recv >= 0 -> poly` branch later in the function never ran.
Symptom in optcarrot: `def wait_frame; Fiber.yield true; end` inside PPU emitted `mrb_int sp_PPU_wait_frame(...)` but the body returned a sp_RbVal — gcc rejected the body with "incompatible types when returning sp_RbVal".
Gate the fallback on `recv < 0`. Same-class self calls are no-recv, so they still resolve here; calls with an explicit receiver fall through to the receiver-aware branches below.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- a9123df66e21
- Parent
- bee7e89d5b64
spinel_codegen.rbmodifiedView file
return @meth_return_types[mi] end # Bare method call in class context if @current_class_idx >= 0 # Bare (no-receiver) method call resolved against the enclosing # class's method table. Only for `recv < 0` — without that guard, # a `Fiber.yield ...` (which has a receiver) inside a class body # would short-circuit here returning the int default and never # reach the Fiber.yield → poly branch further down. if recv < 0 && @current_class_idx >= 0 mr = cls_method_return(@current_class_idx, mname) return mr endtest/class_method_open_class_call.rbaddedView file
Loading diff…