Commit 424f06bf
424f06bf8034Merged
Ryan Seys <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
fix(codegen): wrap Symbol#inspect ":" prefix in SPL marker
sp_str_concat(":", sp_sym_to_s(s)) passed a bare C string literal
to sp_str_byte_len, which reads s[-1] for its marker byte. Under
-O2 this is undefined-behaviour and GCC promotes it to
__builtin_trap. Wrap the prefix with SPL(":") so the marker check
is well-defined.
- compile_call_expr Symbol#inspect (stmt arm): ":" -> SPL(":")
- compile_call_expr Symbol#inspect (expr arm): ":" -> SPL(":")
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 424f06bf8034
- Parent
- f0063046556d
spinel_codegen.rbmodifiedView file
@@ -15720,7 +15720,7 @@
1572015720
return "sp_sym_intern(sp_str_" + mname + "(sp_sym_to_s(" + rc + ")))"1572115721
end1572215722
if mname == "inspect"15723-
return "sp_str_concat(\":\", sp_sym_to_s(" + rc + "))"15723+
return "sp_str_concat(SPL(\":\"), sp_sym_to_s(" + rc + "))"1572415724
end1572515725
if mname == "length" || mname == "size"1572615726
return "((mrb_int)strlen(sp_sym_to_s(" + rc + ")))"@@ -28937,7 +28937,7 @@
2893728937
return "sp_str_inspect(" + val + "->data)"2893828938
end2893928939
if at == "symbol"28940-
return "sp_str_concat(\":\", sp_sym_to_s(" + val + "))"28940+
return "sp_str_concat(SPL(\":\"), sp_sym_to_s(" + val + "))"2894128941
end2894228942
if at == "bool"2894328943
return "(" + val + " ? \"true\" : \"false\")"test/symbol_inspect_spl_marker.rbaddedView file
Loading diff…
test/symbol_inspect_spl_marker.rb.expectedaddedView file
Loading diff…