diff --git a/prism/config.yml b/prism/config.yml index 5ed4cf1b2128ea..edbe4b32d84be5 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 68e016c22a3f50..1f4b9ced5c67fd 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 8badf579e5031c..b608c44f01afce 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 08a949fc017475..fa84af685b5196 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 126ead1800e152..50a82029b5f838 100644 --- a/test/.excludes-prism/TestParse.rb +++ b/test/.excludes-prism/TestParse.rb @@ -5,7 +5,6 @@ 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 090515bbe4efd0..2cf1902348455b 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 8f0cfcf4f45a7a..f2f13e3161c674 100644 --- a/test/.excludes-prism/TestSyntax.rb +++ b/test/.excludes-prism/TestSyntax.rb @@ -9,19 +9,6 @@ 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 6e6e74ee5d5a1d..6cc71f9647172e 100644 --- a/test/prism/errors_test.rb +++ b/test/prism/errors_test.rb @@ -1149,7 +1149,7 @@ def test_duplicated_parameter_names ) assert_errors expected, "def foo(a,b,a);end", [ - ["repeated parameter name", 12..13] + ["duplicated argument name", 12..13] ] end @@ -1169,7 +1169,7 @@ def test_duplicated_parameter_names ) 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 @@ def test_duplicated_parameter_names ) 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 @@ def test_duplicated_parameter_names ) 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 @@ def test_shadow_args_in_lambda 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 @@ def test_repeated_parameter_name_in_destructured_params # 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