зеркало из https://github.com/github/ruby.git
[ruby/prism] Fix eval parsing depth
https://github.com/ruby/prism/commit/89bf7a4948
This commit is contained in:
Родитель
fe9b42f024
Коммит
f38814564b
|
@ -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);
|
||||
|
|
|
@ -42,7 +42,9 @@ module Prism
|
|||
|
||||
assert_kind_of Prism::CallNode, Prism.parse("foo").value.statements.body[0]
|
||||
assert_kind_of Prism::LocalVariableReadNode, Prism.parse("foo", scopes: [[:foo]]).value.statements.body[0]
|
||||
assert_equal 2, Prism.parse("foo", scopes: [[:foo], []]).value.statements.body[0].depth
|
||||
assert_equal 1, Prism.parse("foo", scopes: [[:foo], []]).value.statements.body[0].depth
|
||||
|
||||
assert_equal [:foo], Prism.parse("foo", scopes: [[:foo]]).value.locals
|
||||
end
|
||||
|
||||
def test_literal_value_method
|
||||
|
|
Загрузка…
Ссылка в новой задаче