Commit 64226cf0
64226cf0deb5Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
feat(codegen): support Range#any?/all?/none?/one? with block
The array-shape predicate emitter already iterates ranges via
emit_iter_open; the range method dispatcher just needed to
route the four predicates to it. Without the route, the call
fell through to the unresolved-call warning and returned literal
0 (= falsy), silently mis-evaluating the predicate.
Surfaced via optcarrot's PPU
return if (0..3).all? {|i| @nmt_ref[i] == idxs[i] } — when
the predicate happens to be all-true the early return fires
correctly; when it's all-false the warning's literal 0 happened
to match none? semantics by accident.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 64226cf0deb5
- Parent
- cbc0df9f832d
spinel_codegen.rbmodifiedView file
end return "(" + rc + ".last - " + rc + ".first + 1)" end # `(a..b).any?/all?/none?/one? { |i| ... }` — the array-shape # predicate emitter already iterates ranges via emit_iter_open; # just route to it. Without this, the call falls through to the # unresolved-call warning and emits literal 0. if (mname == "any?" || mname == "all?" || mname == "none?" || mname == "one?") && @nd_block[nid] >= 0 return compile_array_predicate_block(nid, rc, "range", mname) end "" endtest/range_predicate_block.rbaddedView file
Loading diff…
test/range_predicate_block.rb.expectedaddedView file
Loading diff…