Commit 55de4033
55de40337b6aMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): keyword-arg constructor calls coerce arg to ctor param type
SomeClass.new(body: <expr>) lowered the kwarg expression via
compile_expr directly when the ctor param's static type wasn't
"poly". When the expression's runtime type was sp_RbVal (e.g. a
<poly_recv>.<method> chain from compile_poly_method_call), the
raw sp_RbVal flowed into a typed slot (const char *, sp_Hash *,
sp_ *) and clang errored at the call site.
Route through compile_expr_for_expected_type which already handles the unbox / cast for poly->concrete transitions (.v.s, .v.i, ((sp_ *).v.p), etc.).
Closes the last hard error from #685's roundhouse real-blog compile: sp_ActionResponse_new(... body: controller.body ...) where controller is poly-typed and the resulting sp_RbVal flowed into the constructor's const char * body slot. With this and the two prior cls-method fixes (4df3cad, ea08236), all 5 original hard-error shapes are now resolved; remaining issues in the emit are link-time only (missing libsqlite3 dependency).
Tests: default 460/0/0, promote 460/0/0, optcarrot checksum 59662.
Closes #685
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 55de40337b6a
- Parent
- 50106f3cc3dc
spinel_codegen.rbmodifiedView file
if pt == "poly" result = result + box_expr_to_poly(expr_id) else result = result + compile_expr(expr_id) # Route through compile_expr_for_expected_type so a kwarg # whose expression returns sp_RbVal (poly dispatch from a # `<poly_recv>.<method>` chain) gets unboxed to the ctor # param's expected concrete type. Without this, the raw # sp_RbVal flows into a `const char *` slot and clang # errors at the call site (#685, ActionResponse.new(body: # controller.body) where controller is poly-typed). result = result + compile_expr_for_expected_type(expr_id, pt) end found = 1 end