Skip to content

Commit

Permalink
[ruby/prism] Change forwarding error messages to match CRuby
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed Apr 4, 2024
1 parent 2ecf269 commit 440c63d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions prism/templates/src/diagnostic.c.erb
Expand Up @@ -100,9 +100,9 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
[PM_ERR_ARGUMENT_FORWARDING_UNBOUND] = { "unexpected `...` in an non-parenthesized call", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_ARGUMENT_IN] = { "unexpected `in` keyword in arguments", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_ARGUMENT_NO_FORWARDING_AMP] = { "unexpected `&` when the parent method is not forwarding", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES] = { "unexpected `...` when the parent method is not forwarding", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_ARGUMENT_NO_FORWARDING_STAR] = { "unexpected `*` when the parent method is not forwarding", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_ARGUMENT_NO_FORWARDING_STAR_STAR] = { "unexpected `**` when the parent method is not forwarding", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES] = { "unexpected ... when the parent method is not forwarding", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_ARGUMENT_NO_FORWARDING_STAR] = { "unexpected `*`; no anonymous rest parameter", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_ARGUMENT_NO_FORWARDING_STAR_STAR] = { "unexpected `**`; no anonymous keyword rest parameter", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT] = { "unexpected `*` splat argument after a `**` keyword splat argument", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_ARGUMENT_SPLAT_AFTER_SPLAT] = { "unexpected `*` splat argument after a `*` splat argument", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_ARGUMENT_TERM_PAREN] = { "expected a `)` to close the arguments", PM_ERROR_LEVEL_SYNTAX },
Expand Down
8 changes: 4 additions & 4 deletions test/prism/errors_test.rb
Expand Up @@ -290,14 +290,14 @@ def test_break_1

def test_argument_forwarding_when_parent_is_not_forwarding
assert_errors expression('def a(x, y, z); b(...); end'), 'def a(x, y, z); b(...); end', [
["unexpected `...` when the parent method is not forwarding", 18..21]
["unexpected ... when the parent method is not forwarding", 18..21]
]
end

def test_argument_forwarding_only_effects_its_own_internals
assert_errors expression('def a(...); b(...); end; def c(x, y, z); b(...); end'),
'def a(...); b(...); end; def c(x, y, z); b(...); end', [
["unexpected `...` when the parent method is not forwarding", 43..46]
["unexpected ... when the parent method is not forwarding", 43..46]
]
end

Expand Down Expand Up @@ -1054,7 +1054,7 @@ def test_do_not_allow_forward_arguments_in_lambda_literals
)

assert_errors expected, "->(...) {}", [
["unexpected `...` when the parent method is not forwarding", 3..6]
["unexpected ... when the parent method is not forwarding", 3..6]
]
end

Expand All @@ -1078,7 +1078,7 @@ def test_do_not_allow_forward_arguments_in_blocks
)

assert_errors expected, "a {|...|}", [
["unexpected `...` when the parent method is not forwarding", 4..7]
["unexpected ... when the parent method is not forwarding", 4..7]
]
end

Expand Down

0 comments on commit 440c63d

Please sign in to comment.