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
01089710897
end1089810898
10899-
# Issue #314 (A): true when `mname` is defined on 2+ user classes10900-
# (as a method, attr_reader, or attr_writer for `=`-suffixed10901-
# `mname`). Used to gate compile_int_class_fallback_expr — when the10902-
# name is ambiguous across user classes, the "pick first match"10903-
# walk silently grabs an arbitrary class, and an unpinned-mrb_int10904-
# receiver routed through it is almost certainly wrong. Refuse the10905-
# cast and let the unresolved-call placeholder fire instead.10906-
def method_defined_on_multiple_user_classes(mname)10907-
is_writer = 010908-
base_mname = mname10909-
if mname.length > 1 && mname[mname.length - 1] == "="10910-
is_writer = 110911-
base_mname = mname[0, mname.length - 1]10912-
end10913-
count = 010914-
ci = 010915-
while ci < @cls_names.length10916-
found = 010917-
mns = @cls_meth_names[ci].split(";")10918-
jj = 010919-
while jj < mns.length10920-
if mns[jj] == mname10921-
found = 110922-
end10923-
jj = jj + 110924-
end10925-
if found == 010926-
readers = @cls_attr_readers[ci].split(";")10927-
rk = 010928-
while rk < readers.length10929-
if readers[rk] == base_mname10930-
found = 110931-
end10932-
rk = rk + 110933-
end10934-
end10935-
if found == 0 && is_writer == 110936-
writers = @cls_attr_writers[ci].split(";")10937-
wk = 010938-
while wk < writers.length10939-
if writers[wk] == base_mname10940-
found = 110941-
end10942-
wk = wk + 110943-
end10944-
end10945-
if found == 110946-
count = count + 110947-
if count >= 210948-
return 110949-
end10950-
end10951-
ci = ci + 110952-
end10953-
010954-
end10955-
1095610899
# Whitelist of methods defined on built-in primitive types that1095710900
# commonly collide with user-class method names. Mirrors (and1095810901
# delegates the surface to) the predicate