Project

General

Profile

Actions

Feature #4299

closed

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

Added by znz (Kazuhiro NISHIYAMA) almost 14 years ago. Updated about 12 years ago.

Status:
Closed
Target version:
[ruby-dev:43083]

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

Updated by naruse (Yui NARUSE) over 13 years ago

  • Status changed from Open to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

Updated by nahi (Hiroshi Nakamura) over 13 years ago

  • Target version set to 1.9.3
Actions #3

Updated by nobu (Nobuyoshi Nakada) over 13 years ago

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

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

Actions #4

Updated by naruse (Yui NARUSE) over 13 years ago

  • Target version changed from 1.9.3 to 2.0.0

Updated by ko1 (Koichi Sasada) about 12 years ago

  • Target version changed from 2.0.0 to 2.6

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

Actions #6

Updated by nobu (Nobuyoshi Nakada) about 12 years 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 (assign_in_cond): warn for static content object asignments
    in conditional statements. [ruby-dev:43083] [Feature #4299]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0