diff --git a/snapshots/3.3-4.0/end_block_exit.txt b/snapshots/3.3-4.0/end_block_exit.txt index 04e2c3b668..d3252ac6e8 100644 --- a/snapshots/3.3-4.0/end_block_exit.txt +++ b/snapshots/3.3-4.0/end_block_exit.txt @@ -1,10 +1,10 @@ -@ ProgramNode (location: (1,0)-(7,1)) +@ ProgramNode (location: (1,0)-(11,1)) ├── flags: ∅ ├── locals: [] └── statements: - @ StatementsNode (location: (1,0)-(7,1)) + @ StatementsNode (location: (1,0)-(11,1)) ├── flags: ∅ - └── body: (length: 2) + └── body: (length: 3) ├── @ PostExecutionNode (location: (1,0)-(3,1)) │ ├── flags: newline │ ├── statements: @@ -18,16 +18,29 @@ │ ├── keyword_loc: (1,0)-(1,3) = "END" │ ├── opening_loc: (1,4)-(1,5) = "{" │ └── closing_loc: (3,0)-(3,1) = "}" - └── @ PostExecutionNode (location: (5,0)-(7,1)) + ├── @ PostExecutionNode (location: (5,0)-(7,1)) + │ ├── flags: newline + │ ├── statements: + │ │ @ StatementsNode (location: (6,2)-(6,7)) + │ │ ├── flags: ∅ + │ │ └── body: (length: 1) + │ │ └── @ BreakNode (location: (6,2)-(6,7)) + │ │ ├── flags: newline + │ │ ├── arguments: ∅ + │ │ └── keyword_loc: (6,2)-(6,7) = "break" + │ ├── keyword_loc: (5,0)-(5,3) = "END" + │ ├── opening_loc: (5,4)-(5,5) = "{" + │ └── closing_loc: (7,0)-(7,1) = "}" + └── @ PostExecutionNode (location: (9,0)-(11,1)) ├── flags: newline ├── statements: - │ @ StatementsNode (location: (6,2)-(6,7)) + │ @ StatementsNode (location: (10,2)-(10,6)) │ ├── flags: ∅ │ └── body: (length: 1) - │ └── @ BreakNode (location: (6,2)-(6,7)) + │ └── @ NextNode (location: (10,2)-(10,6)) │ ├── flags: newline │ ├── arguments: ∅ - │ └── keyword_loc: (6,2)-(6,7) = "break" - ├── keyword_loc: (5,0)-(5,3) = "END" - ├── opening_loc: (5,4)-(5,5) = "{" - └── closing_loc: (7,0)-(7,1) = "}" + │ └── keyword_loc: (10,2)-(10,6) = "next" + ├── keyword_loc: (9,0)-(9,3) = "END" + ├── opening_loc: (9,4)-(9,5) = "{" + └── closing_loc: (11,0)-(11,1) = "}" diff --git a/snapshots/end_block_exit.txt b/snapshots/end_block_exit.txt deleted file mode 100644 index 4acc5f4218..0000000000 --- a/snapshots/end_block_exit.txt +++ /dev/null @@ -1,20 +0,0 @@ -@ ProgramNode (location: (1,0)-(3,1)) -├── flags: ∅ -├── locals: [] -└── statements: - @ StatementsNode (location: (1,0)-(3,1)) - ├── flags: ∅ - └── body: (length: 1) - └── @ PostExecutionNode (location: (1,0)-(3,1)) - ├── flags: newline - ├── statements: - │ @ StatementsNode (location: (2,2)-(2,6)) - │ ├── flags: ∅ - │ └── body: (length: 1) - │ └── @ NextNode (location: (2,2)-(2,6)) - │ ├── flags: newline - │ ├── arguments: ∅ - │ └── keyword_loc: (2,2)-(2,6) = "next" - ├── keyword_loc: (1,0)-(1,3) = "END" - ├── opening_loc: (1,4)-(1,5) = "{" - └── closing_loc: (3,0)-(3,1) = "}" diff --git a/src/prism.c b/src/prism.c index 3172799283..c046aefce6 100644 --- a/src/prism.c +++ b/src/prism.c @@ -5074,7 +5074,7 @@ pm_interpolated_regular_expression_node_closing_set(pm_parser_t *parser, pm_inte * PM_NODE_FLAG_STATIC_LITERAL indicates that the node should be treated as a * single static literal string that can be pushed onto the stack on its own. * Note that this doesn't necessarily mean that the string will be frozen or - * not; the instructions in CRuby will be either putobject or putstring, + * not; the instructions in CRuby will be either either putobject, dupstring or dupchilledstring, * depending on the combination of `--enable-frozen-string-literal`, * `# frozen_string_literal: true`, and whether or not there is interpolation. * @@ -15332,9 +15332,6 @@ parse_block_exit(pm_parser_t *parser, pm_node_t *node) { if (parser->version < PM_OPTIONS_VERSION_CRUBY_4_1) { return; } - if (PM_NODE_TYPE_P(node, PM_NEXT_NODE)) { - return; - } } PRISM_FALLTHROUGH case PM_CONTEXT_DEF: diff --git a/test/prism/errors/4.1/end_block_exit.txt b/test/prism/errors/4.1/end_block_exit.txt index f8fc59d1a3..a4a1e9bc2c 100644 --- a/test/prism/errors/4.1/end_block_exit.txt +++ b/test/prism/errors/4.1/end_block_exit.txt @@ -3,3 +3,8 @@ END { ^~~~~ Invalid break } +END { + next + ^~~~ Invalid next +} + diff --git a/test/prism/fixtures/3.3-4.0/end_block_exit.txt b/test/prism/fixtures/3.3-4.0/end_block_exit.txt index 53afa1e2f4..8ebf0d6369 100644 --- a/test/prism/fixtures/3.3-4.0/end_block_exit.txt +++ b/test/prism/fixtures/3.3-4.0/end_block_exit.txt @@ -5,3 +5,7 @@ END { END { break } + +END { + next +} diff --git a/test/prism/fixtures/end_block_exit.txt b/test/prism/fixtures/end_block_exit.txt deleted file mode 100644 index 1f64dcb6ed..0000000000 --- a/test/prism/fixtures/end_block_exit.txt +++ /dev/null @@ -1,3 +0,0 @@ -END { - next -}