Project

General

Profile

Actions

Bug #14562

closed

Do not warn for assignment in conditionals inside ()

Added by matsuda (Akira Matsuda) about 6 years ago. Updated about 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-03-01 trunk 62617) [x86_64-darwin16]
[ruby-core:85872]

Description

Ruby warns against this code, which is very helpful.

% ruby -we 'if a=1; p a; end'
-e:1: warning: found = in conditional, should be ==
1

So there's a commonly known practice. In order to express that we're intentionally assigning (not missing one more = sign), we usually add parens around the assignment.

But in fact, Ruby still warns...

% ruby -we 'if (a=1); p a; end'
-e:1: warning: found = in conditional, should be ==
1

Can this behavior changed not to warn when parenthesized?


Related issues 1 (0 open1 closed)

Has duplicate Ruby master - Feature #15848: Silence warning when conditional assignments are wrapped in parenthesesRejectedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0