Commit e589bffc

e589bffcbaedMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · +2 added · ~2 modified

Description

Wire Time#utc? / #tv_usec / #tv_nsec (and usec / nsec / tv_sec / gmt?)

These instance accessors read fields the sp_Time value already carries (is_utc, tv_nsec, tv_sec) but had no codegen entry, so they raised cannot resolve call to '...' on time.

  • utc? / gmt? -> the is_utc presentation flag (bool, like dst?)
  • usec / tv_usec -> microsecond fraction (tv_nsec / 1000)
  • nsec / tv_nsec -> nanosecond fraction
  • tv_sec -> whole epoch seconds (alias of to_i)

analyze types the int group alongside the existing year/hour/... group and the predicate group alongside isdst/dst?; codegen reads the struct fields directly (rc bound once so a side-effecting receiver isn't evaluated twice). Sub-second data is populated by Time.at(Float) and Time.now, so the accessors are exercised end to end without the 7-arg Time.utc(usec) constructor or Time.parse (both separate gaps).

Full suite green (706) and optcarrot checksum unchanged (59662).

Fixes #1111 Fixes #1112 Fixes #1113

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
e589bffcbaed
Parent
af3bc1b7787e

spinel_analyze.rbmodifiedView file

@@ -4511,14 +4511,15 @@
45114511 # receiver so user classes defining same-named methods still
45124512 # flow through normal resolution. Local Time.new is in scope;
45134513 # the fixed-offset 7-arg form is a separate Issue.
4514- if mname == "year" || mname == "mon" || mname == "month" || mname == "mday" || mname == "day" || mname == "hour" || mname == "min" || mname == "sec" || mname == "wday" || mname == "yday" || mname == "utc_offset" || mname == "gmt_offset" || mname == "gmtoff"
4514+ if mname == "year" || mname == "mon" || mname == "month" || mname == "mday" || mname == "day" || mname == "hour" || mname == "min" || mname == "sec" || mname == "wday" || mname == "yday" || mname == "utc_offset" || mname == "gmt_offset" || mname == "gmtoff" || mname == "usec" || mname == "tv_usec" || mname == "nsec" || mname == "tv_nsec" || mname == "tv_sec"
45154515 if recv >= 0 && infer_type(recv) == "time"
45164516 return "int"
45174517 end
45184518 end
4519- # isdst / dst? are predicates: CRuby returns true / false,
4520- # not 0 / 1, so they infer as bool (not the int accessor group).
4521- if mname == "isdst" || mname == "dst?"
4519+ # isdst / dst? and utc? / gmt? are predicates: CRuby returns
4520+ # true / false, not 0 / 1, so they infer as bool (not the int
4521+ # accessor group).
4522+ if mname == "isdst" || mname == "dst?" || mname == "utc?" || mname == "gmt?"
45224523 if recv >= 0 && infer_type(recv) == "time"
45234524 return "bool"
45244525 end