Feature #4299

no warning: found = in conditional, should be ==

Added by Kazuhiro NISHIYAMA over 3 years ago. Updated over 1 year ago.

[ruby-dev:43083]
Status:Closed
Priority:Normal
Assignee:Nobuyoshi Nakada
Category:core
Target version:next minor

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

Associated revisions

Revision 37344
Added by Nobuyoshi Nakada over 1 year ago

parse.y: warn static content assign in cond

  • parse.y (assignincond): warn for static content object asignments in conditional statements. [Feature #4299]

History

#1 Updated by Yui NARUSE almost 3 years ago

  • Status changed from Open to Assigned
  • Assignee set to Nobuyoshi Nakada

#2 Updated by Hiroshi Nakamura almost 3 years ago

  • Target version set to 1.9.3

#3 Updated by Nobuyoshi Nakada almost 3 years ago

  • Tracker changed from Bug to Feature
  • Status changed from Assigned to Feedback

この警告が出るのは、右辺が静的なリテラル(数値と、式展開のない文字列、nil、false、true)であるときだけです。
つまり、実行時に動的に作られるArrayやHashに対して出ないのは意図的なものですが、この条件を拡げるべきだという論点はありうると思います。

#4 Updated by Yui NARUSE almost 3 years ago

  • Target version changed from 1.9.3 to 2.0.0

#5 Updated by Koichi Sasada over 1 year ago

  • Target version changed from 2.0.0 to next minor

放置されているようなので next minor に送っておきます.

#6 Updated by Nobuyoshi Nakada over 1 year ago

  • 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 (assignincond): warn for static content object asignments in conditional statements. [Feature #4299]

Also available in: Atom PDF