summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-03-29 18:25:39 -0400
committerKevin Newton <kddnewton@gmail.com>2024-03-29 19:32:23 -0400
commitcdb8d208c919bbc72b3b07d24c118d3a4af95d11 (patch)
tree71ad8c20ad62b6fcb98244c3ea67b0ebce8fe732
parentd7d59ea172384cac5eae63b39b61c3f09c1f43e3 (diff)
[PRISM] Fix error message for duplicate parameter name
-rw-r--r--prism/config.yml2
-rw-r--r--prism/prism.c2
-rw-r--r--prism/templates/src/diagnostic.c.erb2
-rw-r--r--test/.excludes-prism/TestCall.rb2
-rw-r--r--test/.excludes-prism/TestParse.rb1
-rw-r--r--test/.excludes-prism/TestRegexp.rb6
-rw-r--r--test/.excludes-prism/TestSyntax.rb13
-rw-r--r--test/prism/errors_test.rb12
8 files changed, 13 insertions, 27 deletions
diff --git a/prism/config.yml b/prism/config.yml
index 5ed4cf1b21..edbe4b32d8 100644
--- a/prism/config.yml
+++ b/prism/config.yml
@@ -166,7 +166,7 @@ errors:
- PARAMETER_BLOCK_MULTI
- PARAMETER_CIRCULAR
- PARAMETER_METHOD_NAME
- - PARAMETER_NAME_REPEAT
+ - PARAMETER_NAME_DUPLICATED
- PARAMETER_NO_DEFAULT
- PARAMETER_NO_DEFAULT_KW
- PARAMETER_NUMBERED_RESERVED
diff --git a/prism/prism.c b/prism/prism.c
index 68e016c22a..1f4b9ced5c 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -7176,7 +7176,7 @@ pm_parser_parameter_name_check(pm_parser_t *parser, const pm_token_t *name) {
if (pm_constant_id_list_includes(&parser->current_scope->locals, constant_id)) {
// Add an error if the parameter doesn't start with _ and has been seen before
if ((name->start < name->end) && (*name->start != '_')) {
- pm_parser_err_token(parser, name, PM_ERR_PARAMETER_NAME_REPEAT);
+ pm_parser_err_token(parser, name, PM_ERR_PARAMETER_NAME_DUPLICATED);
}
return true;
}
diff --git a/prism/templates/src/diagnostic.c.erb b/prism/templates/src/diagnostic.c.erb
index 8badf579e5..b608c44f01 100644
--- a/prism/templates/src/diagnostic.c.erb
+++ b/prism/templates/src/diagnostic.c.erb
@@ -249,7 +249,7 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
[PM_ERR_PARAMETER_BLOCK_MULTI] = { "multiple block parameters; only one block is allowed", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_PARAMETER_CIRCULAR] = { "parameter default value references itself", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_PARAMETER_METHOD_NAME] = { "unexpected name for a parameter", PM_ERROR_LEVEL_SYNTAX },
- [PM_ERR_PARAMETER_NAME_REPEAT] = { "repeated parameter name", PM_ERROR_LEVEL_SYNTAX },
+ [PM_ERR_PARAMETER_NAME_DUPLICATED] = { "duplicated argument name", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_PARAMETER_NO_DEFAULT] = { "expected a default value for the parameter", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_PARAMETER_NO_DEFAULT_KW] = { "expected a default value for the keyword parameter", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_PARAMETER_NUMBERED_RESERVED] = { "%.2s is reserved for numbered parameters", PM_ERROR_LEVEL_SYNTAX },
diff --git a/test/.excludes-prism/TestCall.rb b/test/.excludes-prism/TestCall.rb
index 08a949fc01..fa84af685b 100644
--- a/test/.excludes-prism/TestCall.rb
+++ b/test/.excludes-prism/TestCall.rb
@@ -1,3 +1,3 @@
exclude(:test_call_op_asgn_keywords, "unknown")
-exclude(:test_kwsplat_block_order_op_asgn, "unknown")
exclude(:test_call_op_asgn_keywords_mutable, "unknown")
+exclude(:test_kwsplat_block_order_op_asgn, "unknown")
diff --git a/test/.excludes-prism/TestParse.rb b/test/.excludes-prism/TestParse.rb
index 126ead1800..50a82029b5 100644
--- a/test/.excludes-prism/TestParse.rb
+++ b/test/.excludes-prism/TestParse.rb
@@ -5,7 +5,6 @@ exclude(:test_class_module, "unknown")
exclude(:test_disallowed_class_variable, "unknown")
exclude(:test_disallowed_gloal_variable, "unknown")
exclude(:test_disallowed_instance_variable, "unknown")
-exclude(:test_duplicate_argument, "unknown")
exclude(:test_dynamic_constant_assignment, "unknown")
exclude(:test_else_without_rescue, "unknown")
exclude(:test_embedded_rd_error, "unknown")
diff --git a/test/.excludes-prism/TestRegexp.rb b/test/.excludes-prism/TestRegexp.rb
index 090515bbe4..2cf1902348 100644
--- a/test/.excludes-prism/TestRegexp.rb
+++ b/test/.excludes-prism/TestRegexp.rb
@@ -1,6 +1,6 @@
-exclude(:test_unicode_age_14_0, "unknown")
+exclude(:test_invalid_escape_error, "unknown")
exclude(:test_invalid_fragment, "unknown")
-exclude(:test_unicode_age_15_0, "unknown")
exclude(:test_unescape, "unknown")
-exclude(:test_invalid_escape_error, "unknown")
+exclude(:test_unicode_age_14_0, "unknown")
+exclude(:test_unicode_age_15_0, "unknown")
exclude(:test_unicode_age, "unknown")
diff --git a/test/.excludes-prism/TestSyntax.rb b/test/.excludes-prism/TestSyntax.rb
index 8f0cfcf4f4..f2f13e3161 100644
--- a/test/.excludes-prism/TestSyntax.rb
+++ b/test/.excludes-prism/TestSyntax.rb
@@ -9,19 +9,6 @@ exclude(:test_brace_after_literal_argument, "unknown")
exclude(:test_dedented_heredoc_concatenation, "unknown")
exclude(:test_dedented_heredoc_continued_line, "unknown")
exclude(:test_dedented_heredoc_invalid_identifer, "unknown")
-exclude(:test_duplicated_arg, "unknown")
-exclude(:test_duplicated_kw_kwrest, "unknown")
-exclude(:test_duplicated_kw, "unknown")
-exclude(:test_duplicated_opt_kw, "unknown")
-exclude(:test_duplicated_opt_kwrest, "unknown")
-exclude(:test_duplicated_opt_post, "unknown")
-exclude(:test_duplicated_opt_rest, "unknown")
-exclude(:test_duplicated_opt, "unknown")
-exclude(:test_duplicated_rest_kw, "unknown")
-exclude(:test_duplicated_rest_kwrest, "unknown")
-exclude(:test_duplicated_rest_opt, "unknown")
-exclude(:test_duplicated_rest_post, "unknown")
-exclude(:test_duplicated_rest, "unknown")
exclude(:test_duplicated_when, "unknown")
exclude(:test_error_message_encoding, "unknown")
exclude(:test_heredoc_cr, "unknown")
diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb
index 6e6e74ee5d..6cc71f9647 100644
--- a/test/prism/errors_test.rb
+++ b/test/prism/errors_test.rb
@@ -1149,7 +1149,7 @@ module Prism
)
assert_errors expected, "def foo(a,b,a);end", [
- ["repeated parameter name", 12..13]
+ ["duplicated argument name", 12..13]
]
end
@@ -1169,7 +1169,7 @@ module Prism
)
assert_errors expected, "def foo(a,b,*a);end", [
- ["repeated parameter name", 13..14]
+ ["duplicated argument name", 13..14]
]
expected = DefNode(
@@ -1188,7 +1188,7 @@ module Prism
)
assert_errors expected, "def foo(a,b,**a);end", [
- ["repeated parameter name", 14..15]
+ ["duplicated argument name", 14..15]
]
expected = DefNode(
@@ -1207,7 +1207,7 @@ module Prism
)
assert_errors expected, "def foo(a,b,&a);end", [
- ["repeated parameter name", 13..14]
+ ["duplicated argument name", 13..14]
]
expected = DefNode(
@@ -1482,7 +1482,7 @@ module Prism
def test_shadow_args_in_block
source = "tap{|a;a|}"
assert_errors expression(source), source, [
- ["repeated parameter name", 7..8],
+ ["duplicated argument name", 7..8],
]
end
@@ -1491,7 +1491,7 @@ module Prism
# In Ruby 3.0.x, `Ripper.sexp_raw` does not return `nil` for this case.
compare_ripper = RUBY_ENGINE == "ruby" && (RUBY_VERSION.split('.').map { |x| x.to_i } <=> [3, 1]) >= 1
assert_errors expression(source), source, [
- ["repeated parameter name", 14..15],
+ ["duplicated argument name", 14..15],
], compare_ripper: compare_ripper
end