Commit 7cc64b24
7cc64b24149aMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
analyze: merge_refined_local_type accepts time -> float
elapsed = Time.now - start left lv_elapsed as sp_Time even
though codegen emitted a stmt-expression of type mrb_float
((_a.tv_sec - _b.tv_sec) + ...), tripping a C type mismatch.
Root cause: scan_locals' pass 1 walks Time.now - start before
start is declared via declare_var. infer_type(start) returns
the int default; the - arm's time-branch then takes the
"Time - Numeric -> Time" path. Pass 2 re-infers (start declared)
as float per "Time - Time -> Float", but merge_refined_local_type
had no time->float arm and returned "" (no change).
Add the time->float refinement.
Refs #901
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 7cc64b24149a
- Parent
- d3558d524e45
spinel_analyze.rbmodifiedView file
return new_t end end # Issue #901: Time - Time → float. Pass 1 sees the rhs LV as # int (not yet declared) so the `-` arm returns "time" # (Time - Numeric path). Pass 2 re-infers as "float" once the # rhs LV is declared as time. Accept the refinement. if cur_t == "time" && new_t == "float" return new_t end "" endtest/time_subtraction_returns_float.rbaddedView file
Loading diff…
test/time_subtraction_returns_float.rb.expectedaddedView file
Loading diff…