summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--prism/prism.c2
-rw-r--r--test/prism/errors_test.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/prism/prism.c b/prism/prism.c
index e922e18f31..c84092ea68 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -9782,7 +9782,7 @@ parse_block_parameters(
}
pm_block_parameters_node_t *block_parameters = pm_block_parameters_node_create(parser, parameters, opening);
- if (accept1(parser, PM_TOKEN_SEMICOLON)) {
+ if ((opening->type != PM_TOKEN_NOT_PROVIDED) && accept1(parser, PM_TOKEN_SEMICOLON)) {
do {
expect1(parser, PM_TOKEN_IDENTIFIER, PM_ERR_BLOCK_PARAM_LOCAL_VARIABLE);
pm_parser_local_add_token(parser, &parser->previous);
diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb
index 399653ef3e..cb58b3cd21 100644
--- a/test/prism/errors_test.rb
+++ b/test/prism/errors_test.rb
@@ -1363,6 +1363,16 @@ module Prism
]
end
+ def test_shadow_args_in_lambda
+ source = "->a;b{}"
+ assert_errors expression(source), source, [
+ ["Expected a `do` keyword or a `{` to open the lambda block", 3..3],
+ ["Expected a newline or semicolon after the statement", 7..7],
+ ["Cannot parse the expression", 7..7],
+ ["Expected a lambda block beginning with `do` to end with `end`", 7..7],
+ ]
+ end
+
private
def assert_errors(expected, source, errors, compare_ripper: RUBY_ENGINE == "ruby")