diff options
author | Kevin Newton <kddnewton@gmail.com> | 2023-12-15 10:07:55 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-12-15 15:19:50 +0000 |
commit | f38814564b1c8d9394ae4568fb0dfd2bbbfe3440 (patch) | |
tree | 3981602be866059faed755b2b3759482fac7581a /prism | |
parent | fe9b42f024eb3724b0853c914916ea7a97fd30a6 (diff) |
[ruby/prism] Fix eval parsing depth
https://github.com/ruby/prism/commit/89bf7a4948
Diffstat (limited to 'prism')
-rw-r--r-- | prism/prism.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/prism/prism.c b/prism/prism.c index 5746399ff7..a382a6b18c 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -17185,9 +17185,14 @@ parse_expression(pm_parser_t *parser, pm_binding_power_t binding_power, bool acc static pm_node_t * parse_program(pm_parser_t *parser) { - pm_parser_scope_push(parser, !parser->current_scope); - parser_lex(parser); + // If the current scope is NULL, then we want to push a new top level scope. + // The current scope could exist in the event that we are parsing an eval + // and the user has passed into scopes that already exist. + if (parser->current_scope == NULL) { + pm_parser_scope_push(parser, true); + } + parser_lex(parser); pm_statements_node_t *statements = parse_statements(parser, PM_CONTEXT_MAIN); if (!statements) { statements = pm_statements_node_create(parser); |