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 #360] Fix an error when the Array core class contains a writer method #361

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

Earlopain
Copy link
Contributor

Fix #360

This is a syntax error:

def foo=(...)
end

So it must use public_send instead in that case. It's caused by

ARRAY_METHODS =
(Array.instance_methods - Object.instance_methods - [:to_a]).freeze

By default the Array class doesn't contain such methods but when something like spring is in use, code can be evaluated before rubocop.

I thought about simply rejecting such methods but supporting it is easy enough

… writer method

This is a syntax error:
```
def foo=(...)
end
```

So it must use `public_send` instead in that case. It's caused by https://github.com/rubocop/rubocop-ast/blob/47e0eead4b84c3d28d7251a548e152f914219773/lib/rubocop/ast/node/mixin/collection_node.rb#L9-L10

By default the `Array` class doesn't contain such methods but when something like spring
is in use, code can be evaluated before rubocop.

I thought about simply rejecting such methods but supporting it is easy enough
@marcandre marcandre merged commit 5459734 into rubocop:master Feb 25, 2025
22 checks passed
@marcandre
Copy link
Contributor

Thanks!

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.

faster is not better when it booms
2 participants