Commit 9d606199
9d60619944abMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(analyze): RBS-arbitration accepts any literal arm for declared untyped
untyped (which spinel maps internally to "poly") is the top
type — every literal arm satisfies it. The arbitration check was
flagging def get: () -> untyped against a literal nil return
with "declared poly but a literal expression infers nil".
Surfaced in action_dispatch/session.rb's Session#[] where the
RBS declares untyped and the body's fall-through arm returns
nil.
Mirror the #638 nil-vs-T? fix, generalized: when rbs_t is the
top type, no literal inferred type conflicts.
Closes #650.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 9d60619944ab
- Parent
- 1eaa5d48ad81
spinel_analyze.rbmodifiedView file
@@ -20435,6 +20435,18 @@
2043520435
if base_type(rbs_t) == base_type(inf_t)2043620436
return false2043720437
end20438+
# Issue #650: declared `untyped` (which maps to spinel's internal20439+
# "poly") is the top type — any literal arm satisfies it. Mirrors20440+
# #638's `T?` accept-nil, generalized to "any inf_t".20441+
if rbs_t == "poly"20442+
return false20443+
end20444+
# Issue #650: declared `untyped` (which maps to spinel's internal20445+
# "poly") is the top type — any literal arm satisfies it. Mirrors20446+
# #638's `T?` accept-nil, generalized to "any inf_t".20447+
if rbs_t == "poly"20448+
return false20449+
end2043820450
# Issue #638: a declared nullable return (`String?` = `String |2043920451
# nil`) is satisfied by a literal `nil` return. Accept the nil2044020452
# arm rather than flagging conflict.