From ccec209b2cced2ddb8463c4933ef729a44d0363c Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Tue, 6 Feb 2024 11:59:49 -0500 Subject: [PRISM] Fix fsl coming from file --- iseq.c | 9 ++++++++- prism_compile.c | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/iseq.c b/iseq.c index e2e9b4d6e7..440270bd29 100644 --- a/iseq.c +++ b/iseq.c @@ -1002,8 +1002,15 @@ pm_iseq_new_with_opt(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpa .end_pos = { .lineno = (int) end.line, .column = (int) end.column } }; + rb_compile_option_t *current_option = (rb_compile_option_t *) option; + if (node->parser->frozen_string_literal) { + rb_compile_option_t new_option = *option; + new_option.frozen_string_literal = true; + current_option = &new_option; + } + prepare_iseq_build(iseq, name, path, realpath, first_lineno, &code_location, -1, - parent, isolated_depth, type, Qnil, option); + parent, isolated_depth, type, Qnil, current_option); pm_iseq_compile_node(iseq, node); finish_iseq_build(iseq); diff --git a/prism_compile.c b/prism_compile.c index c529c4d88c..2e1666524f 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -773,12 +773,13 @@ pm_interpolated_node_compile(pm_node_list_t *parts, rb_iseq_t *iseq, NODE dummy_ current_string = rb_enc_str_new(NULL, 0, enc); } - if (parser->frozen_string_literal) { + if (ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal) { ADD_INSN1(ret, &dummy_line_node, putobject, rb_str_freeze(current_string)); } else { ADD_INSN1(ret, &dummy_line_node, putstring, rb_str_freeze(current_string)); } + current_string = Qnil; number_of_items_pushed++; @@ -793,12 +794,14 @@ pm_interpolated_node_compile(pm_node_list_t *parts, rb_iseq_t *iseq, NODE dummy_ if (RTEST(current_string)) { current_string = rb_fstring(current_string); - if (parser->frozen_string_literal) { + + if (ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal) { ADD_INSN1(ret, &dummy_line_node, putobject, current_string); } else { ADD_INSN1(ret, &dummy_line_node, putstring, current_string); } + current_string = Qnil; number_of_items_pushed++; } -- cgit v1.2.3