Actions
Bug #19919
closedVariable assignments in condition are warned however class variable assignment and constant declaration are not warned
Description
Is it better to warn for class variable assignment and constant declaration in condition?
(x, y = 1, 2) ? x : y # test.rb:1: warning: found `= literal' in conditional, should be ==
if a = 1 # test.rb:3: warning: found `= literal' in conditional, should be ==
end
b = 1
1.times do
if b = 2 # test.rb:8: warning: found `= literal' in conditional, should be ==
end
end
if $a = 1 # test.rb:12: warning: found `= literal' in conditional, should be ==
end
if @a = 1 # test.rb:15: warning: found `= literal' in conditional, should be ==
end
class A
if @@a = 1 # no warning
end
end
if B = 1 # no warning
end
I use ruby 3.3.0preview2 (2023-09-14 master e50fcca9a7)
.
Actions
Like1
Like0Like0