Commit 78b2bcf4
78b2bcf41002Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
fix(analyze): mark_hash_needs on every infer_hash_val_type result (#415)
{ sym_key: <ivar-or-param> } hash literals whose values were not
string literals (an ivar read, a param, a method call) emitted a
function signature that referenced sp_SymStrHash * but didn't
emit the matching typedef + helpers in the same translation unit:
error: unknown type name 'sp_SymStrHash'; did you mean 'sp_StrStrHash'? static inline sp_SymStrHash * sp_Foo_attributes(sp_Foo *self);
The string-literal case ({ title: "hello" }) happened to work
because the literal-collecting path flagged the variant via
compose_hash_type. The ivar/param/method-call case took a
different path through infer_hash_val_type, which returned the
variant string but never flagged its template-instantiation need.
@needs_sym_str_hash stayed at 0, emit_hash_runtime skipped
the typedef, and the cc step failed.
Fix: split infer_hash_val_type into a thin wrapper +
infer_hash_val_type_raw impl, route every wrapper return
through the existing mark_hash_needs helper. Catches every
hash variant the inference produces — sym_str_hash,
sym_int_hash, str_str_hash, int_str_hash, sym_poly_hash,
str_poly_hash, poly_poly_hash — and matches the flagging the
literal path already does.
Closes #415
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 78b2bcf41002
- Parent
- fe8cf4d54652
spinel_analyze.rbmodifiedView file
end def infer_hash_val_type(nid) rt = infer_hash_val_type_raw(nid) # Issue #415: every observed hash variant must flag its template # need so emit_hash_runtime instantiates the typedef + helpers. # Without this the `{ sym: @ivar }` shape — where the value's # concrete type is only resolved on a later inference iteration # via the value cache — emits `sp_SymStrHash *` references with # no matching typedef in the translation unit. mark_hash_needs(rt) rt end def infer_hash_val_type_raw(nid) elems = parse_id_list(@nd_elements[nid]) if elems.length > 0 eid = elems[0]test/sym_keyed_hash_ivar_value.rbaddedView file
Loading diff…
test/sym_keyed_hash_ivar_value.rb.expectedaddedView file
Loading diff…