Commit 7d0ffa89

7d0ffa899c0aMerged

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

Description

Add hash values / each_pair

Hash#values codegen (StrInt/StrStr/IntStr -> value array; IntInt has no runtime helper) and each_pair as an alias for hash each (analyze block params + codegen iteration).

make test: 22.

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

Details

Commit
7d0ffa899c0a
Parent
e74f9687ff35

src/analyze.cmodifiedView file

@@ -880,8 +880,8 @@
880880 ty_is_array(rt))
881881 pt = ty_array_elem(rt);
882882
883- /* hash.each { |k, v| } binds two params */
884- if (!strcmp(name, "each") && ty_is_hash(rt)) {
883+ /* hash.each / each_pair { |k, v| } binds two params */
884+ if ((!strcmp(name, "each") || !strcmp(name, "each_pair")) && ty_is_hash(rt)) {
885885 Scope *hs = comp_scope_of(c, block);
886886 LocalVar *kp = scope_local_intern(hs, p0); kp->is_block_param = 1;
887887 TyKind km = ty_unify(kp->type, ty_hash_key(rt));