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

@@ -25593,6 +25593,13 @@
2559325593 end
2559425594 return "(" + rc + ".last - " + rc + ".first + 1)"
2559525595 end
25596+ # `(a..b).any?/all?/none?/one? { |i| ... }` — the array-shape
25597+ # predicate emitter already iterates ranges via emit_iter_open;
25598+ # just route to it. Without this, the call falls through to the
25599+ # unresolved-call warning and emits literal 0.
25600+ if (mname == "any?" || mname == "all?" || mname == "none?" || mname == "one?") && @nd_block[nid] >= 0
25601+ return compile_array_predicate_block(nid, rc, "range", mname)
25602+ end
2559625603 ""
2559725604 end
2559825605