Commit 3a49dca8
3a49dca8ca44Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
codegen: nullable poly / untyped default emits sp_box_nil() not NULL
`def self.X -> untyped?` lowers to an `sp_RbVal`-returning function. The dead-code fallback `return NULL` at the function tail didn't unify with the struct return type, breaking the C compile when the RBS-declared return is `untyped?` or `poly?`. Emit `sp_box_nil()` for nullable poly / untyped so the fallback type-checks.
Fixes #915
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 3a49dca8ca44
- Parent
- 06aa166698f2
spinel_codegen.rbmodifiedView file
@@ -4604,6 +4604,12 @@
46044604
if is_value_type_obj(bt_n) == 146054605
return "{0}"46064606
end4607+
# Issue #915: nullable poly / untyped lowers to sp_RbVal (a4608+
# struct); the function-return-type fallback was emitting bare4609+
# NULL which doesn't unify with sp_RbVal.4610+
if bt_n == "poly" || bt_n == "untyped"4611+
return "sp_box_nil()"4612+
end46074613
return "NULL"46084614
end46094615
# NOTE: nullable returns above, so rest handles base types only