summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2021-10-26 01:58:01 +0900
committerGitHub <noreply@github.com>2021-10-26 01:58:01 +0900
commit09fa773e04f183e5eb685f07e174efa2cf77f9dc (patch)
tree43b58901056217443ddfcee79decd2a9c71596cc /parse.y
parent33113c6b64b9017e8b31b6c5e9cbcd7bdf30f05a (diff)
ast.c: Use kept script_lines data instead of re-opening the source file (#5019)
ast.c: Use kept script_lines data instead of re-open the source file
Notes
Notes: Merged-By: mame <mame@ruby-lang.org>
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y1
1 files changed, 1 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 2ec9d7770c..5948f6e2f6 100644
--- a/parse.y
+++ b/parse.y
@@ -6414,6 +6414,7 @@ lex_getline(struct parser_params *p)
VALUE line = (*p->lex.gets)(p, p->lex.input);
if (NIL_P(line)) return line;
must_be_ascii_compatible(line);
+ if (RB_OBJ_FROZEN(line)) line = rb_str_dup(line); // needed for RubyVM::AST.of because script_lines in iseq is deep-frozen
#ifndef RIPPER
if (p->debug_lines) {
rb_enc_associate(line, p->enc);