summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-09-02 23:12:22 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-09-30 22:15:28 +0900
commit7b2bea42a245f2e80b5d2700963fd6b143f6d6b8 (patch)
tree59bc4509242d0be9f92dc8a5a95d65d6903a4455 /compile.c
parent65e8a293892800d2201899de51d19ed7ce362bbf (diff)
Unfreeze string-literal-only interpolated string-literal
[Feature #17104]
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index 797a170f5f..0d2d7fbf73 100644
--- a/compile.c
+++ b/compile.c
@@ -3828,8 +3828,16 @@ static int
compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node)
{
int cnt;
- CHECK(compile_dstr_fragments(iseq, ret, node, &cnt));
- ADD_INSN1(ret, nd_line(node), concatstrings, INT2FIX(cnt));
+ if (!node->nd_next) {
+ VALUE lit = rb_fstring(node->nd_lit);
+ const int line = (int)nd_line(node);
+ ADD_INSN1(ret, line, putstring, lit);
+ RB_OBJ_WRITTEN(iseq, Qundef, lit);
+ }
+ else {
+ CHECK(compile_dstr_fragments(iseq, ret, node, &cnt));
+ ADD_INSN1(ret, nd_line(node), concatstrings, INT2FIX(cnt));
+ }
return COMPILE_OK;
}