Project

General

Profile

Actions

Bug #13872

closed

Duplicate assignment no longer silences "assigned but unused variable" warning

Added by segiddins (Samuel Giddins) about 7 years ago. Updated about 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-09-04 trunk 59742) [x86_64-darwin16]
[ruby-core:82656]

Description

On ruby 2.4.1:

ruby -W -e 'def a; var = var = "foo"; end'

prints no warning

On ruby 2.5.0dev (2017-09-04 trunk 59742) [x86_64-darwin16]

ruby -W -e 'def a; var = var = "foo"; end'

prints warning -e:1: warning: assigned but unused variable - var

This feature was useful when the local binding would be passed to another scope (like to ERB), and those variables were only accessed via the binding

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0