Commit e7a21d11
e7a21d11862aMerged
Tomoyuki INOUE <[email protected]> · 6 months ago · 4 files · ~4 modified
Description
fix(analyze,codegen): Time#isdst / #dst? return bool, not int
Review (matz/spinel#565, gemini-code-assist medium): isdst / dst? were grouped with the integer accessors and inferred as "int", so p t.isdst / t.dst? printed 0/1 instead of CRuby's false/true. Split them into a dedicated bool inference arm; codegen emits the boolean expression (sp_time_isdst(...) != 0). sp_time_isdst's 0/1 return is unchanged, runtime untouched. test/time_accessors.rb now covers Time.at(0).utc.isdst / .dst? (TZ-independent, both false); .expected regenerated from CRuby 3.4.6, byte-identical. make / bootstrap (4 fixpoints) / make test 533 pass all green.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- e7a21d11862a
- Parent
- 17a0a15dbe77
spinel_analyze.rbmodifiedView file
# receiver so user classes defining same-named methods still # flow through normal resolution. Local Time.new is in scope; # the fixed-offset 7-arg form is a separate Issue. if mname == "year" || mname == "mon" || mname == "month" || mname == "mday" || mname == "day" || mname == "hour" || mname == "min" || mname == "sec" || mname == "wday" || mname == "yday" || mname == "isdst" || mname == "dst?" || mname == "utc_offset" || mname == "gmt_offset" || mname == "gmtoff" 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" if recv >= 0 && infer_type(recv) == "time" return "int" end end # isdst / dst? are predicates: CRuby returns true / false, # not 0 / 1, so they infer as bool (not the int accessor group). if mname == "isdst" || mname == "dst?" if recv >= 0 && infer_type(recv) == "time" return "bool" end end if mname == "zone" if recv >= 0 && infer_type(recv) == "time" return "string"spinel_codegen.rbmodifiedView file
Loading diff…
test/time_accessors.rbmodifiedView file
Loading diff…
test/time_accessors.rb.expectedmodifiedView file
Loading diff…