Feature #4299
closed
no warning: found = in conditional, should be ==
Added by znz (Kazuhiro NISHIYAMA) over 13 years ago.
Updated almost 12 years ago.
Description
=begin
http://d.hatena.ne.jp/nagachika/20110119/ruby_trunk_changes_30595_30603
で知ったのですが、右辺の種類によっては「warning: found = in conditional, should be ==」が出ないことがあるようです。
% ruby-trunk -ve '!=""'
ruby 1.9.3dev (2011-01-20 trunk 30614) [i686-linux]
-e:1: warning: found = in conditional, should be ==
% ruby-trunk -ve '!=1'
ruby 1.9.3dev (2011-01-20 trunk 30614) [i686-linux]
-e:1: warning: found = in conditional, should be ==
% ruby-trunk -ve '!={}'
ruby 1.9.3dev (2011-01-20 trunk 30614) [i686-linux]
% ruby-trunk -ve '!=[]'
ruby 1.9.3dev (2011-01-20 trunk 30614) [i686-linux]
%
=end
- Status changed from Open to Assigned
- Assignee set to nobu (Nobuyoshi Nakada)
- Target version set to 1.9.3
- Tracker changed from Bug to Feature
- Status changed from Assigned to Feedback
この警告が出るのは、右辺が静的なリテラル(数値と、式展開のない文字列、nil、false、true)であるときだけです。
つまり、実行時に動的に作られるArrayやHashに対して出ないのは意図的なものですが、この条件を拡げるべきだという論点はありうると思います。
- Target version changed from 1.9.3 to 2.0.0
- Target version changed from 2.0.0 to 2.6
放置されているようなので next minor に送っておきます.
- Status changed from Feedback to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r37344.
Kazuhiro, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
parse.y: warn static content assign in cond
- parse.y (assign_in_cond): warn for static content object asignments
in conditional statements. [ruby-dev:43083] [Feature #4299]
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0