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

@@ -6433,6 +6433,9 @@
64336433 if bt == "fiber" || bt == "bigint"
64346434 return 1
64356435 end
6436+ if bt == "exception"
6437+ return 1
6438+ end
64366439 if is_obj_type(bt) == 1
64376440 return 1
64386441 end