Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to check multiple block arguments for forwarding arg #2113

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

makenowjust
Copy link
Contributor

Fix #2111

@@ -56,6 +56,7 @@ static const char* const diagnostic_messages[PM_DIAGNOSTIC_ID_LEN] = {
[PM_ERR_ARGUMENT_AFTER_BLOCK] = "unexpected argument after a block argument",
[PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES] = "unexpected argument after `...`",
[PM_ERR_ARGUMENT_BARE_HASH] = "unexpected bare hash argument",
[PM_ERR_ARGUMENT_BLOCK_FORWARDING] = "both a block argument and a forwarding argument; only one block is allowed",
[PM_ERR_ARGUMENT_BLOCK_MULTI] = "multiple block arguments; only one block is allowed",
Copy link
Member

@andrykonchin andrykonchin Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to use PM_ERR_ARGUMENT_BLOCK_MULTI message instead?

In all the other cases with two block arguments Prism returns multiple block arguments; only one block is allowed error:

def bar(&)
  foo(&) { }
end

def bar()
  foo(&:to_s) { }
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense of course. However, I believe the detailed error message helps users, so I introduce the new error message for this.

@kddnewton kddnewton merged commit cac2261 into ruby:main Jan 2, 2024
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing SyntaxError for ... and explicit block argument
3 participants