Commit 289ce84b

289ce84baf6fMerged

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

Description

Return a real array from Module/Class#instance_methods(false)

M.instance_methods(false) const-folded to a sym-array boxed as an opaque SP_BUILTIN_SYM_ARRAY object. p inspected it fine, but chained operations saw the box as an empty array: M.instance_methods(false).map(&:to_s).sort returned [] (and the class form failed to compile).

Build a real sp_PolyArray of boxed symbols and box it as a poly array, so the value matches its declared TY_POLY_ARRAY type and the generic poly-array path (map / sort / include? / length / class) iterates it. Also adds SP_BUILTIN_POLY_ARRAY to sp_poly_class_name's Array case so a boxed poly array reports its class as Array (previously empty -- a latent gap this surfaced).

Fixes #1401 Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]

Details

Commit
289ce84baf6f
Parent
b4f21c798b7f

lib/sp_runtime.hmodifiedView file

@@ -3062,7 +3062,7 @@
30623062 switch (v.cls_id) {
30633063 case SP_BUILTIN_INT_ARRAY: case SP_BUILTIN_FLT_ARRAY:
30643064 case SP_BUILTIN_STR_ARRAY: case SP_BUILTIN_SYM_ARRAY:
3065- case SP_BUILTIN_PTR_ARRAY: return SPL("Array");
3065+ case SP_BUILTIN_PTR_ARRAY: case SP_BUILTIN_POLY_ARRAY: return SPL("Array");
30663066 case SP_BUILTIN_RANGE: return SPL("Range");
30673067 case SP_BUILTIN_TIME: return SPL("Time");
30683068 case SP_BUILTIN_EXCEPTION: return sp_exc_class_name((volatile struct sp_Exception_s *)v.v.p);