aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--prism/diagnostic.c1
-rw-r--r--prism/diagnostic.h1
-rw-r--r--prism/prism.c2
-rw-r--r--test/prism/errors_test.rb15
4 files changed, 19 insertions, 0 deletions
diff --git a/prism/diagnostic.c b/prism/diagnostic.c
index 1fc8c50cb5..b3a8282cda 100644
--- a/prism/diagnostic.c
+++ b/prism/diagnostic.c
@@ -62,6 +62,7 @@ static const char* const diagnostic_messages[PM_DIAGNOSTIC_ID_LEN] = {
[PM_ERR_ARGUMENT_FORMAL_GLOBAL] = "invalid formal argument; formal argument cannot be a global variable",
[PM_ERR_ARGUMENT_FORMAL_IVAR] = "invalid formal argument; formal argument cannot be an instance variable",
[PM_ERR_ARGUMENT_FORWARDING_UNBOUND] = "unexpected `...` in an non-parenthesized call",
+ [PM_ERR_ARGUMENT_IN] = "unexpected `in` keyword in arguments",
[PM_ERR_ARGUMENT_NO_FORWARDING_AMP] = "unexpected `&` when the parent method is not forwarding",
[PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES] = "unexpected `...` when the parent method is not forwarding",
[PM_ERR_ARGUMENT_NO_FORWARDING_STAR] = "unexpected `*` when the parent method is not forwarding",
diff --git a/prism/diagnostic.h b/prism/diagnostic.h
index fc1f0c2b4b..c88a704488 100644
--- a/prism/diagnostic.h
+++ b/prism/diagnostic.h
@@ -53,6 +53,7 @@ typedef enum {
PM_ERR_ARGUMENT_FORMAL_GLOBAL,
PM_ERR_ARGUMENT_FORMAL_IVAR,
PM_ERR_ARGUMENT_FORWARDING_UNBOUND,
+ PM_ERR_ARGUMENT_IN,
PM_ERR_ARGUMENT_NO_FORWARDING_AMP,
PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES,
PM_ERR_ARGUMENT_NO_FORWARDING_STAR,
diff --git a/prism/prism.c b/prism/prism.c
index 79258386d6..61c1d6784b 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -11338,6 +11338,8 @@ parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_for
}
parsed_bare_hash = true;
+ } else if (accept1(parser, PM_TOKEN_KEYWORD_IN)) {
+ pm_parser_err_current(parser, PM_ERR_ARGUMENT_IN);
}
parse_arguments_append(parser, arguments, argument);
diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb
index 51ac7bc5cf..57c0719aa7 100644
--- a/test/prism/errors_test.rb
+++ b/test/prism/errors_test.rb
@@ -1997,6 +1997,21 @@ module Prism
end
end
+ def test_command_call_in
+ source = <<~RUBY
+ foo 1 in a
+ a = foo 2 in b
+ RUBY
+ message1 = 'unexpected `in` keyword in arguments'
+ message2 = 'expected a newline or semicolon after the statement'
+ assert_errors expression(source), source, [
+ [message1, 9..10],
+ [message2, 8..8],
+ [message1, 24..25],
+ [message2, 23..23],
+ ]
+ end
+
def test_constant_assignment_in_method
source = 'def foo();A=1;end'
assert_errors expression(source), source, [