Commit 86a3cdc0
86a3cdc0b7c8Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · ~4 modified
Description
Fix poly[poly] index, uninit attr nil, FFI const type inference, ivar-op= expr
- sp_poly_index_poly: dispatch poly[poly_key] at runtime by key tag; fixes unsupported-call errors when both receiver and index are TY_POLY
- Uninit attr widening: scalar attr_accessor/attr_reader ivar with no initialize in the class chain widens to TY_POLY (sp_box_nil init), so a fresh instance reads nil instead of the zero-init'd scalar default; Struct classes are excluded since their members are set by the ctor
- InstanceVariableOperatorWriteNode in emit_expr: handle @ivar OP= as a last expression in a block (not just as a statement)
- FFI const type inference: Module::CONST for ffi_const declarations now resolves to TY_INT so bitwise operations (Flags::READ | Flags::WRITE) compile correctly
Together these fix bundle_classd_49 (ERR->PASS): 780 pass, 5 fail, 60 error vs prior 779 pass, 5 fail, 61 error.
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Details
- Commit
- 86a3cdc0b7c8
- Parent
- b6ca2e981e94
lib/sp_runtime.hmodifiedView file
@@ -4013,6 +4013,13 @@
40134013
return sp_StrPolyHash_get((sp_StrPolyHash*)a.v.p, sp_sym_name_fn ? sp_sym_name_fn((sp_sym)i) : "");40144014
return sp_poly_arr_get(a, i);40154015
}4016+
/* poly[poly_key]: dispatch on key tag at runtime. */4017+
static sp_RbVal sp_poly_index_poly(sp_RbVal recv, sp_RbVal idx) {4018+
if (idx.tag == SP_TAG_STR) return sp_poly_get_str(recv, idx.v.s);4019+
if (idx.tag == SP_TAG_SYM) return sp_poly_get_sym(recv, (sp_sym)idx.v.i);4020+
mrb_int i = (idx.tag == SP_TAG_INT) ? idx.v.i : 0;4021+
return sp_poly_arr_get_hash(recv, i);4022+
}40164023
static sp_RbVal sp_poly_arr_set_hash(sp_RbVal v, mrb_int idx, sp_RbVal val) {40174024
if (v.tag != SP_TAG_OBJ) return val;40184025
switch (v.cls_id) {src/analyze.cmodifiedView file
Loading diff…
src/codegen.cmodifiedView file
Loading diff…
src/compiler.hmodifiedView file
Loading diff…