Commit d7a62e51
d7a62e512691Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
fix(codegen): interpolation of a Symbol renders the name, not the sym id
compile_interpolated's per-type dispatch had no symbol arm, so
"#{sym}" fell through to the default int path and printed the raw
sp_sym id. Add a symbol arm that emits sp_sym_to_s(...), the same
helper SymbolNode literals already route through.
puts sym and explicit sym.to_s already worked because they live
on different codepaths.
Fixes #633.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- d7a62e512691
- Parent
- 85f780538ecd
spinel_codegen.rbmodifiedView file
@@ -11961,6 +11961,14 @@
1196111961
@needs_class_table = 11196211962
fmt = fmt + "%s"1196311963
arg_exprs.push("sp_class_to_s(" + compile_expr(inner) + ")")11964+
elsif it == "symbol"11965+
# Symbol values carry the sp_sym int id;11966+
# interpolation must render the registered11967+
# name, mirroring Symbol#to_s. Without this11968+
# arm the default int path printed the raw11969+
# id. Issue #633.11970+
fmt = fmt + "%s"11971+
arg_exprs.push("sp_sym_to_s(" + compile_expr(inner) + ")")1196411972
else1196511973
fmt = fmt + "%lld"1196611974
arg_exprs.push("(long long)" + compile_expr(inner))test/interpolation_symbol_name.expectedaddedView file
Loading diff…
test/interpolation_symbol_name.rbaddedView file
Loading diff…