@@ -556,7 +556,7 @@ parse_regexp_concat(rb_iseq_t *iseq, const pm_scope_node_t *scope_node, const pm
556
556
static void pm_compile_node (rb_iseq_t * iseq , const pm_node_t * node , LINK_ANCHOR * const ret , bool popped , pm_scope_node_t * scope_node );
557
557
558
558
static int
559
- pm_interpolated_node_compile (rb_iseq_t * iseq , const pm_node_list_t * parts , const pm_node_location_t * node_location , LINK_ANCHOR * const ret , bool popped , pm_scope_node_t * scope_node , rb_encoding * implicit_regexp_encoding , rb_encoding * explicit_regexp_encoding )
559
+ pm_interpolated_node_compile (rb_iseq_t * iseq , const pm_node_list_t * parts , const pm_node_location_t * node_location , LINK_ANCHOR * const ret , bool popped , pm_scope_node_t * scope_node , rb_encoding * implicit_regexp_encoding , rb_encoding * explicit_regexp_encoding , bool mutable_result )
560
560
{
561
561
int stack_size = 0 ;
562
562
size_t parts_size = parts -> size ;
@@ -666,7 +666,7 @@ pm_interpolated_node_compile(rb_iseq_t *iseq, const pm_node_list_t *parts, const
666
666
if (RTEST (current_string )) {
667
667
current_string = rb_fstring (current_string );
668
668
669
- if (stack_size == 0 && interpolated ) {
669
+ if (stack_size == 0 && ( interpolated || mutable_result ) ) {
670
670
PUSH_INSN1 (ret , current_location , putstring , current_string );
671
671
}
672
672
else {
@@ -690,7 +690,7 @@ pm_compile_regexp_dynamic(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_
690
690
rb_encoding * explicit_regexp_encoding = parse_regexp_encoding (scope_node , node );
691
691
rb_encoding * implicit_regexp_encoding = explicit_regexp_encoding != NULL ? explicit_regexp_encoding : scope_node -> encoding ;
692
692
693
- int length = pm_interpolated_node_compile (iseq , parts , node_location , ret , popped , scope_node , implicit_regexp_encoding , explicit_regexp_encoding );
693
+ int length = pm_interpolated_node_compile (iseq , parts , node_location , ret , popped , scope_node , implicit_regexp_encoding , explicit_regexp_encoding , false );
694
694
PUSH_INSN2 (ret , * node_location , toregexp , INT2FIX (parse_regexp_flags (node ) & 0xFF ), INT2FIX (length ));
695
695
}
696
696
@@ -9637,7 +9637,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
9637
9637
}
9638
9638
else {
9639
9639
const pm_interpolated_string_node_t * cast = (const pm_interpolated_string_node_t * ) node ;
9640
- int length = pm_interpolated_node_compile (iseq , & cast -> parts , & location , ret , popped , scope_node , NULL , NULL );
9640
+ int length = pm_interpolated_node_compile (iseq , & cast -> parts , & location , ret , popped , scope_node , NULL , NULL , ! PM_NODE_FLAG_P ( cast , PM_INTERPOLATED_STRING_NODE_FLAGS_FROZEN ) );
9641
9641
if (length > 1 ) PUSH_INSN1 (ret , location , concatstrings , INT2FIX (length ));
9642
9642
if (popped ) PUSH_INSN (ret , location , pop );
9643
9643
}
@@ -9648,7 +9648,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
9648
9648
// :"foo #{bar}"
9649
9649
// ^^^^^^^^^^^^^
9650
9650
const pm_interpolated_symbol_node_t * cast = (const pm_interpolated_symbol_node_t * ) node ;
9651
- int length = pm_interpolated_node_compile (iseq , & cast -> parts , & location , ret , popped , scope_node , NULL , NULL );
9651
+ int length = pm_interpolated_node_compile (iseq , & cast -> parts , & location , ret , popped , scope_node , NULL , NULL , false );
9652
9652
9653
9653
if (length > 1 ) {
9654
9654
PUSH_INSN1 (ret , location , concatstrings , INT2FIX (length ));
@@ -9670,7 +9670,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
9670
9670
9671
9671
PUSH_INSN (ret , location , putself );
9672
9672
9673
- int length = pm_interpolated_node_compile (iseq , & cast -> parts , & location , ret , false, scope_node , NULL , NULL );
9673
+ int length = pm_interpolated_node_compile (iseq , & cast -> parts , & location , ret , false, scope_node , NULL , NULL , false );
9674
9674
if (length > 1 ) PUSH_INSN1 (ret , location , concatstrings , INT2FIX (length ));
9675
9675
9676
9676
PUSH_SEND_WITH_FLAG (ret , location , idBackquote , INT2NUM (1 ), INT2FIX (VM_CALL_FCALL | VM_CALL_ARGS_SIMPLE ));
0 commit comments