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 a false positive for endless method definition #796

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/parser/ruby30.y
Expand Up @@ -3071,7 +3071,7 @@ require 'parser'
end
def endless_method_name(name_t)
if name_t[0].end_with?('=')
if !%w[=== == != <= >=].include?(name_t[0]) && name_t[0].end_with?('=')
diagnostic :error, :endless_setter, nil, name_t
end
end
2 changes: 1 addition & 1 deletion lib/parser/ruby31.y
Expand Up @@ -3071,7 +3071,7 @@ require 'parser'
end
def endless_method_name(name_t)
if name_t[0].end_with?('=')
if !%w[=== == != <= >=].include?(name_t[0]) && name_t[0].end_with?('=')
diagnostic :error, :endless_setter, nil, name_t
end
end
13 changes: 13 additions & 0 deletions test/test_parser.rb
Expand Up @@ -10107,6 +10107,19 @@ def test_endless_setter
SINCE_3_0)
end

def test_endless_comparison_method
%i[=== == != <= >= !=].each do |method_name|
assert_parses(
s(:def, method_name,
s(:args,
s(:arg, :other)),
s(:send, nil, :do_something)),
%Q{def #{method_name}(other) = do_something},
%q{},
SINCE_3_0)
end
end

def test_endless_method_without_args
assert_parses(
s(:def, :foo,
Expand Down