Commit f21ef72e

f21ef72eb68dMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 3 files · +2 added · ~1 modified

Description

Merge pull request #1028 from rubys/fix/1027-stringinterp-mutable-str

codegen: add mutable_str arm to string-interpolation format dispatch (#1027)

Details

Commit
f21ef72eb68d
Parent
633216ee4e1e
Merge parent
542c20b4dce9

spinel_codegen.rbmodifiedView file

@@ -15138,6 +15138,14 @@
1513815138 elsif it == "sym_array_ptr_array"
1513915139 fmt = fmt + "%s"
1514015140 arg_exprs.push("sp_SymArrayPtrArray_inspect(" + compile_expr(inner) + ")")
15141+ elsif it == "mutable_str"
15142+ # `"#{s}"` on an sp_String * (the mutable variant
15143+ # backing `String.new` + `<<`) reads the chars via
15144+ # sp_String_cstr; without this arm the default int
15145+ # fallback printed the pointer cast to long long.
15146+ # Issue #1027.
15147+ fmt = fmt + "%s"
15148+ arg_exprs.push("sp_String_cstr(" + compile_expr(inner) + ")")
1514115149 else
1514215150 fmt = fmt + "%lld"
1514315151 arg_exprs.push("(long long)" + compile_expr(inner))