Commit 1a848867
1a848867956fMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
fix(analyze): widen nil-default local to exception in rescue assign
raised = nil seeds the local as nil, then rescue => e; raised = e
assigns an sp_Exception *. The slot's widening logic (in scan_locals
and scan_poly_assigns) routes nil + T → T? only when T is in
is_nullable_pointer_type, but exception was missing from that
list. The slot therefore stayed mrb_int and the assignment failed
with incompatible pointer to integer conversion.
Add exception (= sp_Exception *) to is_nullable_pointer_type so
the nil-default widening path produces a nullable pointer slot for
this shape, matching the existing fix for nil-default-with-typed-
reassignment in #634.
Fixes #696
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 1a848867956f
- Parent
- c76a30308df0
spinel_analyze.rbmodifiedView file
if bt == "fiber" || bt == "bigint" return 1 end if bt == "exception" return 1 end if is_obj_type(bt) == 1 return 1 endtest/rescue_widens_nil_local_to_exception.expectedaddedView file
Loading diff…
test/rescue_widens_nil_local_to_exception.rbaddedView file
Loading diff…