Commit b6aa7295
b6aa7295b902Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · +2 added · ~2 modified
Description
Return nil from Float#infinite? for a finite value
x.infinite? returned 0 for a finite Float; CRuby returns nil (and
-1/+1 for -Inf/+Inf). Type it as the nullable int? and emit SP_INT_NIL
in the finite branch. Truthiness in a condition is unchanged (a finite
value stays falsy).
0.0.infinite? # => nil (was 0) (1.0/0.0).infinite? # => 1 (-1.0/0.0).infinite? # => -1
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- b6aa7295b902
- Parent
- 955516b668f5
spinel_analyze.rbmodifiedView file
@@ -5572,7 +5572,7 @@
55725572
return "bool"55735573
end55745574
if mname == "infinite?"5575-
return "int"5575+
return "int?"55765576
end55775577
if mname == "tally"55785578
if recv >= 0spinel_codegen.rbmodifiedView file
Loading diff…
test/float_infinite_nil.rbaddedView file
Loading diff…
test/float_infinite_nil.rb.expectedaddedView file
Loading diff…