Commit 6c4e6179
6c4e6179309cMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Array#assoc / #rassoc on poly arrays
assoc(key) returns the sub-array whose first element matches key; rassoc(val) matches the second element; a miss yields nil (a NULL sp_PolyArray, which inspects as "nil"). Lowers to the existing sp_PolyArray_assoc / _rassoc with the boxed key.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 6c4e6179309c
- Parent
- d5ed9a21cd1c
src/analyze.cmodifiedView file
@@ -472,6 +472,8 @@
472472
!strcmp(name, "compact") || !strcmp(name, "flatten") ||473473
!strcmp(name, "values_at")) return rt;474474
if (!strcmp(name, "[]=")) return ty_array_elem(rt);475+
if ((!strcmp(name, "assoc") || !strcmp(name, "rassoc")) && rt == TY_POLY_ARRAY)476+
return TY_POLY_ARRAY; /* the matching sub-array, or nil (NULL ptr) */475477
}476478
477479
/* exception receiver methods */src/codegen.cmodifiedView file
Loading diff…