Commit 98860702
988607023b3eMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · +2 added · ~2 modified
Description
Implement Time#to_s and fix puts nil rendering
Two of the gaps reported in #1222:
-
Time#to_s was unresolved (the receiver inferred as int). Infer it as string and reuse sp_time_inspect_v, which already renders the "YYYY-MM-DD HH:MM:SS +ZZZZ" form (no subsecond fraction) that to_s uses. Time#inspect, which adds nanoseconds, is unchanged.
-
puts nilandputs nil.itselfprinted0instead of an empty line: compile_puts had no nil arm, so a nil-typed argument fell through to the int printf. Add one gated on the syntactic form (a nil literal, or.itselfon a nil receiver), not the inferred "nil" type -- a module/ivar accessor can infer as "nil" while carrying a real int value, and printing those as empty would silently drop the value.
Of the other reported items, callee (J2) and String#clone (J5) already worked; Struct#to_h-with-block and Struct#dig remain.
Refs #1222
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 988607023b3e
- Parent
- ead258d27f8d
spinel_analyze.rbmodifiedView file
# methods sharing the names (rare in idiomatic Ruby; possible # if a class wraps date arithmetic) still flow through normal # resolution. if mname == "iso8601" || mname == "strftime" if mname == "iso8601" || mname == "strftime" || mname == "to_s" if recv >= 0 && infer_type(recv) == "time" return "string" endspinel_codegen.rbmodifiedView file
Loading diff…
test/puts_nil.rbaddedView file
Loading diff…
test/time_to_s.rbaddedView file
Loading diff…