Commit 594d6f14
594d6f144320Merged
NHH <[email protected]> · 5 months ago · 3 files · +2 added · ~1 modified
Description
Fix Array#first/#last on empty int_array returning SP_INT_NIL instead of nil
The analyzer typed int_array#first and int_array#last as returning "int", so the codegen emitted sp_int_to_s(sp_IntArray_get(arr, 0)) which prints the SP_INT_NIL sentinel as a huge negative number. Returning "int?" routes through sp_int_opt_inspect, which correctly prints "nil" for the sentinel.
Details
- Commit
- 594d6f144320
- Parent
- 155ec59a2269
spinel_analyze.rbmodifiedView file
@@ -5709,6 +5709,9 @@
57095709
if rt == "poly_array"57105710
return "poly"57115711
end5712+
if rt == "int_array"5713+
return "int?"5714+
end57125715
end57135716
return "int"57145717
endtest/array_first_last_empty.rbaddedView file
Loading diff…
test/array_first_last_empty.rb.expectedaddedView file
Loading diff…