Commit 5304881e

5304881e9b7bMerged

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

Description

fix: nullable param type for nil + object in detect_poly_params

When a function is called with both nil and an object type (e.g. depth(root) and depth(nil)), infer the parameter type as nullable (obj_Node?) instead of degrading to poly (sp_RbVal).

Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]

Details

Commit
5304881e9b7b
Parent
7d80595bb260

spinel_codegen.rbmodifiedView file

@@ -5931,6 +5931,14 @@
59315931 elsif is_nullable_type(ct) == 0 && is_nullable_pointer_type(ct) == 1
59325932 ptypes[k] = ct + "?"
59335933 end
5934+ elsif at == "nil" && is_nullable_pointer_type(ct) == 1
5935+ # nil + T → T?
5936+ if is_nullable_type(ct) == 0
5937+ ptypes[k] = ct + "?"
5938+ end
5939+ elsif ct == "nil" && is_nullable_pointer_type(at) == 1
5940+ # T + nil (ct was nil, at is T) → T?
5941+ ptypes[k] = at + "?"
59345942 else
59355943 # Genuinely different types - mark poly
59365944 ptypes[k] = "poly"