Commit c20c6a7e
c20c6a7e0d0bMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 3 files · +1 added · ~2 modified
Description
Implement Kernel#Complex(re, im)
The no-receiver Complex(re, im) conversion fell through to the integer
0 fallback. Dispatch it to an sp_Complex value (imaginary part defaults
to 0), coercing each part to mrb_float, mirroring the literal emitted for
imaginary literals and Complex.polar. analyze types the call as complex.
Addresses #1281.
Fixes #1281
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- c20c6a7e0d0b
- Parent
- 6308be6334bb
spinel_analyze.rbmodifiedView file
@@ -4783,6 +4783,11 @@
47834783
if recv < 0 && mname == "String"47844784
return "string"47854785
end4786+
# Kernel#Complex(re, im) builds an sp_Complex value, same type as4787+
# Complex.polar and an imaginary literal.4788+
if recv < 0 && mname == "Complex"4789+
return "complex"4790+
end47864791
# Float#ceil(n)/floor(n)/round(n)/truncate(n) with n given return47874792
# Float; zero-arg / Integer#ceil etc. return Integer. (truncate's arm47884793
# used to live next to nan?/infinite? — folded in here for one placespinel_codegen.rbmodifiedView file
Loading diff…
test/kernel_complex.rbaddedView file
Loading diff…