Commit 74709165

74709165bb61Merged

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

Description

Hash#delete returning the deleted value

delete(key) now returns the deleted value (nil on a miss, matching CRuby) and removes the key, for the variants with a runtime delete helper (str_int / str_str / sym_poly). Regenerated hash_delete_returns_value's expected from CRuby: a missing-key delete is nil, not the legacy int 0.

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

Details

Commit
74709165bb61
Parent
9e058673b861

src/analyze.cmodifiedView file

@@ -579,6 +579,7 @@
579579 if (!strcmp(name, "[]")) return ty_hash_val(rt);
580580 if (!strcmp(name, "[]=")) return ty_hash_val(rt);
581581 if (!strcmp(name, "fetch")) return ty_hash_val(rt);
582+ if (!strcmp(name, "delete")) return ty_hash_val(rt);
582583 if (!strcmp(name, "length") || !strcmp(name, "size") ||
583584 !strcmp(name, "count")) return TY_INT;
584585 if (!strcmp(name, "keys")) return ty_array_of(ty_hash_key(rt));