@@ -557,7 +557,7 @@ parse_regexp_concat(rb_iseq_t *iseq, const pm_scope_node_t *scope_node, const pm
557557static 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 );
558558
559559static int
560- 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 )
560+ 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 )
561561{
562562 int stack_size = 0 ;
563563 size_t parts_size = parts -> size ;
@@ -667,7 +667,7 @@ pm_interpolated_node_compile(rb_iseq_t *iseq, const pm_node_list_t *parts, const
667667 if (RTEST (current_string )) {
668668 current_string = rb_fstring (current_string );
669669
670- if (stack_size == 0 && interpolated ) {
670+ if (stack_size == 0 && ( interpolated || mutable_result ) ) {
671671 PUSH_INSN1 (ret , current_location , putstring , current_string );
672672 }
673673 else {
@@ -691,7 +691,7 @@ pm_compile_regexp_dynamic(rb_iseq_t *iseq, const pm_node_t *node, const pm_node_
691691 rb_encoding * explicit_regexp_encoding = parse_regexp_encoding (scope_node , node );
692692 rb_encoding * implicit_regexp_encoding = explicit_regexp_encoding != NULL ? explicit_regexp_encoding : scope_node -> encoding ;
693693
694- int length = pm_interpolated_node_compile (iseq , parts , node_location , ret , popped , scope_node , implicit_regexp_encoding , explicit_regexp_encoding );
694+ int length = pm_interpolated_node_compile (iseq , parts , node_location , ret , popped , scope_node , implicit_regexp_encoding , explicit_regexp_encoding , false );
695695 PUSH_INSN2 (ret , * node_location , toregexp , INT2FIX (parse_regexp_flags (node ) & 0xFF ), INT2FIX (length ));
696696}
697697
@@ -9575,7 +9575,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
95759575 }
95769576 else {
95779577 const pm_interpolated_string_node_t * cast = (const pm_interpolated_string_node_t * ) node ;
9578- int length = pm_interpolated_node_compile (iseq , & cast -> parts , & location , ret , popped , scope_node , NULL , NULL );
9578+ 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 ) );
95799579 if (length > 1 ) PUSH_INSN1 (ret , location , concatstrings , INT2FIX (length ));
95809580 if (popped ) PUSH_INSN (ret , location , pop );
95819581 }
@@ -9586,7 +9586,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
95869586 // :"foo #{bar}"
95879587 // ^^^^^^^^^^^^^
95889588 const pm_interpolated_symbol_node_t * cast = (const pm_interpolated_symbol_node_t * ) node ;
9589- int length = pm_interpolated_node_compile (iseq , & cast -> parts , & location , ret , popped , scope_node , NULL , NULL );
9589+ int length = pm_interpolated_node_compile (iseq , & cast -> parts , & location , ret , popped , scope_node , NULL , NULL , false );
95909590
95919591 if (length > 1 ) {
95929592 PUSH_INSN1 (ret , location , concatstrings , INT2FIX (length ));
@@ -9608,7 +9608,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
96089608
96099609 PUSH_INSN (ret , location , putself );
96109610
9611- int length = pm_interpolated_node_compile (iseq , & cast -> parts , & location , ret , false, scope_node , NULL , NULL );
9611+ int length = pm_interpolated_node_compile (iseq , & cast -> parts , & location , ret , false, scope_node , NULL , NULL , false );
96129612 if (length > 1 ) PUSH_INSN1 (ret , location , concatstrings , INT2FIX (length ));
96139613
96149614 PUSH_SEND_WITH_FLAG (ret , location , idBackquote , INT2NUM (1 ), INT2FIX (VM_CALL_FCALL | VM_CALL_ARGS_SIMPLE ));
0 commit comments