Commit d2fb361c
d2fb361c09ebMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Infer hash block params for mutating iteration methods; fix yields guard in class_new
- Add delete_if, select!, reject!, filter!, keep_if to the hash block param inference list so k/v params are typed correctly.
- Guard emit_class_new initialize call with !yields to prevent emitting a call to a function that was lowered inline and never generated.
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Details
- Commit
- d2fb361c09eb
- Parent
- 6031b4e17eac
src/analyze.cmodifiedView file
@@ -5074,13 +5074,16 @@
50745074
}50755075
50765076
/* hash.each / each_pair { |k, v| } or { |(k,v)| } binds two params.5077-
Also handles each_with_object { |(k,v), memo| }. */5077+
Also handles each_with_object { |(k,v), memo| } and mutating5078+
iteration (delete_if / select! / reject! / keep_if). */50785079
if ((!strcmp(name, "each") || !strcmp(name, "each_pair") || !strcmp(name, "map") ||50795080
!strcmp(name, "collect") || !strcmp(name, "flat_map") || !strcmp(name, "select") ||50805081
!strcmp(name, "filter") || !strcmp(name, "reject") || !strcmp(name, "find") ||50815082
!strcmp(name, "detect") || !strcmp(name, "sort_by") || !strcmp(name, "min_by") ||50825083
!strcmp(name, "max_by") || !strcmp(name, "count") || !strcmp(name, "sum") ||50835084
!strcmp(name, "any?") || !strcmp(name, "all?") || !strcmp(name, "none?") ||5085+
!strcmp(name, "delete_if") || !strcmp(name, "select!") || !strcmp(name, "reject!") ||5086+
!strcmp(name, "filter!") || !strcmp(name, "keep_if") ||50845087
!strcmp(name, "each_with_index") || !strcmp(name, "each_with_object")) && ty_is_hash(rt)) {50855088
Scope *hs = comp_scope_of(c, block);50865089
/* |(k,v)| or |(k,v), memo| destructuring (MultiTargetNode first param) */src/codegen.cmodifiedView file
Loading diff…