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 nil and puts nil.itself printed 0 instead 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 .itself on 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

@@ -4565,7 +4565,7 @@
45654565 # methods sharing the names (rare in idiomatic Ruby; possible
45664566 # if a class wraps date arithmetic) still flow through normal
45674567 # resolution.
4568- if mname == "iso8601" || mname == "strftime"
4568+ if mname == "iso8601" || mname == "strftime" || mname == "to_s"
45694569 if recv >= 0 && infer_type(recv) == "time"
45704570 return "string"
45714571 end