Commit b8690def

b8690def4d92Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

fix(codegen): drop unused method_defined_on_multiple_user_classes helper

The helper was added in 243702c as a "future tightening" for the int-class fallback's first-match-wins behavior, but it's never called. Spinel still emits its body, and the body uses mname.length

  • mname[i] directly without a string-pinning call site — so type inference defaults the param to mrb_int and the emitted C compares sp_StrArray elements with mrb_int values via sp_str_eq. gcc accepts this with -Wint-conversion warnings; clang rejects it as an error (default in clang 16+), failing the macos / ubuntu-clang / windows- mingw CI legs of every PR rebased onto master.

The body-walker fix in 243702c stands alone — the helper was defensive infrastructure for a path that never landed. Drop it. Re-introduce when/if it's actually needed, structured to expose the string param type to spinel's inference (e.g. via an early is_primitive_shared_method(mname) == 1-style call that anchors the type).

Refs #314

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

Details

Commit
b8690def4d92
Parent
6116445752a8

spinel_codegen.rbmodifiedView file

@@ -10896,63 +10896,6 @@
1089610896 0
1089710897 end
1089810898
10899- # Issue #314 (A): true when `mname` is defined on 2+ user classes
10900- # (as a method, attr_reader, or attr_writer for `=`-suffixed
10901- # `mname`). Used to gate compile_int_class_fallback_expr — when the
10902- # name is ambiguous across user classes, the "pick first match"
10903- # walk silently grabs an arbitrary class, and an unpinned-mrb_int
10904- # receiver routed through it is almost certainly wrong. Refuse the
10905- # cast and let the unresolved-call placeholder fire instead.
10906- def method_defined_on_multiple_user_classes(mname)
10907- is_writer = 0
10908- base_mname = mname
10909- if mname.length > 1 && mname[mname.length - 1] == "="
10910- is_writer = 1
10911- base_mname = mname[0, mname.length - 1]
10912- end
10913- count = 0
10914- ci = 0
10915- while ci < @cls_names.length
10916- found = 0
10917- mns = @cls_meth_names[ci].split(";")
10918- jj = 0
10919- while jj < mns.length
10920- if mns[jj] == mname
10921- found = 1
10922- end
10923- jj = jj + 1
10924- end
10925- if found == 0
10926- readers = @cls_attr_readers[ci].split(";")
10927- rk = 0
10928- while rk < readers.length
10929- if readers[rk] == base_mname
10930- found = 1
10931- end
10932- rk = rk + 1
10933- end
10934- end
10935- if found == 0 && is_writer == 1
10936- writers = @cls_attr_writers[ci].split(";")
10937- wk = 0
10938- while wk < writers.length
10939- if writers[wk] == base_mname
10940- found = 1
10941- end
10942- wk = wk + 1
10943- end
10944- end
10945- if found == 1
10946- count = count + 1
10947- if count >= 2
10948- return 1
10949- end
10950- end
10951- ci = ci + 1
10952- end
10953- 0
10954- end
10955-
1095610899 # Whitelist of methods defined on built-in primitive types that
1095710900 # commonly collide with user-class method names. Mirrors (and
1095810901 # delegates the surface to) the predicate