Commit e9b94657
e9b946576a44Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · +1 added · ~1 modified
Description
Unbox poly setter value into narrow attr_accessor field
When an inherited factory (def self.create; new(attrs); end) forwards
an incompatible argument type to a subclass constructor, the ctor
parameter unifies to poly (sp_RbVal) across its call sites. If the
inherited attr_accessor field it is assigned to stays narrow (mrb_int,
pinned elsewhere by @id = 0), the inlined self.attr = val setter
wrote the poly value directly into the narrow field, emitting
mrb_int = sp_RbVal which fails C compilation.
Add the missing slot-concrete / arg-poly case to the setter's coercion ladder: unbox the poly value to the field's concrete C type. This mirrors the existing poly-receiver dispatch arm. Any program that previously compiled could not have reached this case (it was an ill-typed assignment), so the change is additive.
Fixes #1275
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- e9b946576a44
- Parent
- c688e6c3270a
spinel_codegen.rbmodifiedView file
end if slot_t == "poly" arg0_w = box_value_to_poly(arg_t_aw, arg0_w) elsif arg_t_aw == "poly" && slot_t != "" && slot_t != "poly" # An inherited factory widened the subclass ctor param to poly # (e.g. `self.create` forwarding `new(attrs)` with a Hash) while # this attr_accessor field stayed narrow. Unbox to the field's # concrete C type so the direct write type-checks instead of # emitting `mrb_int = sp_RbVal`. Mirrors the poly-receiver # dispatch arm's slot-concrete / arg-poly case. arg0_w = unbox_poly_to(slot_t, arg0_w) elsif slot_t == "bigint" && arg_t_aw == "int" # promote-mode-widened ivar: wrap an int rhs. @needs_bigint = 1test/inherited_factory_poly_param_narrow_attr.rbaddedView file
Loading diff…