Commit 7f339cf1
7f339cf18824Merged
Ryan Seys <[email protected]> · 5 months ago · 4 files · +2 added · ~2 modified
Description
analyze,codegen: implement Range#exclude_end?
(1...5).exclude_end? previously fell through to the unresolved-call
warning and raised undefined method 'exclude_end?' for range. Add an
analyzer arm so the call types as bool (printed as true / false),
and a codegen arm that reads the runtime excl flag off the sp_Range
struct, so it is correct for both literal ... / .. ranges and
non-literal sp_Range values.
The earlier version of this change also reworked size / length /
count, but master has since brought those onto the same runtime-excl
lowering (last - first + 1 - excl), so only exclude_end? remains.
The test passes ranges through a method parameter so a non-literal
sp_Range receiver (whose excl is unknown at compile time) actually
exercises the runtime-flag read, and keeps the literal size / count /
length assertions as a regression guard.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 7f339cf18824
- Parent
- e314f84e9ac8
spinel_analyze.rbmodifiedView file
if mname == "overlap?" return "bool" end if mname == "exclude_end?" return "bool" end if mname == "===" return "bool" endspinel_codegen.rbmodifiedView file
Loading diff…
test/range_exclude_end_size.rbaddedView file
Loading diff…
test/range_exclude_end_size.rb.expectedaddedView file
Loading diff…