diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-09-02 23:12:22 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-09-30 22:15:28 +0900 |
commit | 7b2bea42a245f2e80b5d2700963fd6b143f6d6b8 (patch) | |
tree | 59bc4509242d0be9f92dc8a5a95d65d6903a4455 /compile.c | |
parent | 65e8a293892800d2201899de51d19ed7ce362bbf (diff) |
Unfreeze string-literal-only interpolated string-literal
[Feature #17104]
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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; } |