Project

General

Profile

Feature #4299

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

Added by znz (Kazuhiro NISHIYAMA) almost 7 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
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

Associated revisions

Revision 37344
Added by nobu (Nobuyoshi Nakada) about 5 years ago

parse.y: warn static content assign in cond

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

Revision 37344
Added by nobu (Nobuyoshi Nakada) about 5 years ago

parse.y: warn static content assign in cond

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

Revision 37344
Added by nobu (Nobuyoshi Nakada) about 5 years ago

parse.y: warn static content assign in cond

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

Revision 37344
Added by nobu (Nobuyoshi Nakada) about 5 years ago

parse.y: warn static content assign in cond

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

History

#1 [ruby-dev:43918] Updated by naruse (Yui NARUSE) over 6 years ago

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

#2 [ruby-dev:43927] Updated by nahi (Hiroshi Nakamura) over 6 years ago

  • Target version set to 1.9.3

#3 Updated by nobu (Nobuyoshi Nakada) over 6 years ago

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

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

#4 Updated by naruse (Yui NARUSE) over 6 years ago

  • Target version changed from 1.9.3 to 2.0.0

#5 [ruby-dev:46279] Updated by ko1 (Koichi Sasada) about 5 years ago

  • Target version changed from 2.0.0 to next minor

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

#6 Updated by nobu (Nobuyoshi Nakada) about 5 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. [Feature #4299]

Also available in: Atom PDF