Commit b1f6dabc

b1f6dabcd2acMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified

Description

Array/Range all?/any?/none?/one? with a block

Loop over the elements, count the truthy block results, and reduce to the predicate. An empty array literal folds to its constant regardless of the block (which never runs).

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
b1f6dabcd2ac
Parent
c250483716ce

src/analyze.cmodifiedView file

@@ -630,6 +630,8 @@
630630 !strcmp(name, "eql?") || !strcmp(name, "==") || !strcmp(name, "!=") ||
631631 !strcmp(name, "overlap?")) return TY_BOOL;
632632 if (!strcmp(name, "step")) return TY_INT_ARRAY;
633+ if (!strcmp(name, "all?") || !strcmp(name, "any?") ||
634+ !strcmp(name, "none?") || !strcmp(name, "one?")) return TY_BOOL;
633635 if (!strcmp(name, "each") && nt_ref(nt, id, "block") < 0) return TY_INT_ARRAY;
634636 if (!strcmp(name, "sum") || !strcmp(name, "min") || !strcmp(name, "max") ||
635637 !strcmp(name, "first") || !strcmp(name, "last") ||