Commit 99913081
99913081f3fcMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 3 files · +2 added · ~1 modified
Description
Inspect a nullable int (int?) as nil in p / inspect contexts
compile_inspect_for had no int? arm, so p on a nullable int (0.nonzero?,
[].first, an int? local) fell through to the no-inspect fallback and
printed a blank line instead of "nil". Route int? through sp_int_opt_inspect,
which prints "nil" for the SP_INT_NIL sentinel and the decimal otherwise --
matching the existing .inspect method path.
Fixes #1088
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 99913081f3fc
- Parent
- 25ecab1089d0
spinel_codegen.rbmodifiedView file
@@ -40255,6 +40255,11 @@
4025540255
if at == "int"4025640256
return "sp_int_to_s(" + val + ")"4025740257
end40258+
if at == "int?"40259+
# Nullable int (e.g. `0.nonzero?`, `[].first`): print "nil" for the40260+
# SP_INT_NIL sentinel, the decimal otherwise.40261+
return "sp_int_opt_inspect(" + val + ")"40262+
end4025840263
if at == "float"4025940264
return "sp_float_inspect(" + val + ")"4026040265
endtest/int_opt_p_inspect.rbaddedView file
Loading diff…
test/int_opt_p_inspect.rb.expectedaddedView file
Loading diff…