From: "matz (Yukihiro Matsumoto) via ruby-core" Date: 2023-10-12T04:49:51+00:00 Subject: [ruby-core:115009] [Ruby master Bug#19919] Variable assignments in condition are warned however class variable assignment and constant declaration are not warned Issue #19919 has been updated by matz (Yukihiro Matsumoto). This should be addressed. Matz. ---------------------------------------- Bug #19919: Variable assignments in condition are warned however class variable assignment and constant declaration are not warned https://bugs.ruby-lang.org/issues/19919#change-104877 * Author: yui-knk (Kaneko Yuichiro) * Status: Open * Priority: Normal * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Is it better to warn for class variable assignment and constant declaration in condition? ```ruby (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)`. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/