Commit 66e7a44e
66e7a44e4dc8Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): mutable_str -> string coerce at call boundary
Functions whose body builds a mutable string (io = ""; io << "..."; io;) had their return type inferred as mutable_str, but downstream
callers with const char * params got the raw sp_String * pointer
and clang errored with -Wincompatible-pointer-types.
compile_expr_for_expected_type's expected_base == "string" arm
handled int/bigint/float/bool/nil/symbol -> string coerces but
omitted the mutable_str case. Add the arm: emit (val)->data to
extract the underlying buffer.
Clears 6 of the 18 remaining warnings in #685's roundhouse emit (every sp_ActionController_Base_render() callsite passing an sp_Views_Articles_cls_() result).
Tests: default 460/0/0, promote 460/0/0, optcarrot checksum 59662.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 66e7a44e4dc8
- Parent
- 55de40337b6a
spinel_codegen.rbmodifiedView file
if at == "symbol" return "sp_sym_to_s(" + val + ")" end # sp_String * (the mutable_str builder type) -> const char *: read # the underlying buffer via `->data`. Surfaces whenever a function # whose body builds a mutable string (`io = ""; io << "..."; io;`) # gets passed to a callee with a const char * param. The function's # return type was inferred too narrowly upstream, but the call site # can recover at the boundary. if at == "mutable_str" return "(" + val + ")->data" end end if is_obj_type(expected_base) == 1 && at == "poly" cname = expected_base[4, expected_base.length - 4]