Commit 422245e7

422245e741bfMerged

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

Description

Widen nil-typed call args to poly in bind_call_params

When a call site passes nil explicitly (e.g. obj.set(nil)), the param's inferred type was TY_NIL which is not a valid scalar C type, causing a hard error. Widen nil arguments to TY_POLY in bind_call_params so the param becomes sp_RbVal.

Also add fetch(key,{}) empty-hash-default detection in both analyze and codegen (already committed); this commit records the TY_NIL fix.

Co-Authored-By: Claude Sonnet 4.6 [email protected]

Details

Commit
422245e741bf
Parent
410a62ab30fd

src/analyze.cmodifiedView file

@@ -3052,6 +3052,8 @@
30523052 at = ty_is_array(arr) ? ty_array_elem(arr) : TY_POLY;
30533053 } else {
30543054 at = infer_type(c, argv[k]);
3055+ /* nil is not a first-class param type; a nil arg widens the param to poly */
3056+ if (at == TY_NIL) at = TY_POLY;
30553057 }
30563058 LocalVar *p = scope_local(m, m->pnames[k]);
30573059 if (!p) continue;