Issue #12490 has been updated by Shyouhei Urabe.


We looked at this issue at yesterday's developer meeting.  While myself was positive to this, Matz is not.  He thinks that shadowing by itself is a bad habit and should be discouraged.  You need to show him a good advantage of encouraging variable shadowing to persuade him.

----------------------------------------
Feature #12490: Remove warning on shadowing block params
https://bugs.ruby-lang.org/issues/12490#change-60034

* Author: Soutaro Matsumoto
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Running ruby with -w option reports warnings on shadowing block params.

~~~
$ cat -n w.rb
     1	a = [1]
     2	
     3	a.each do |a|
     4	  a = 3
     5	end
     6	
     7	p a
$ ruby -cw w.rb
w.rb:3: warning: shadowing outer local variable - a
Syntax OK
~~~

I would like to propose to remove the warning.

It was introduced to ruby 1.9, a version which changes behaviors on conflicts of local vars and block param. I understand it is to tell the user the change, and let them fix if their program depends on 1.8 behavior. ruby 1.9.1 is released in 2009, almost seven years ago, and most ruby programmers today would have correct understanding of current behavior. In my opinion, the warning does not make sense now but just annoying.

* I like giving block params shadowing name to avoid finding new good names
* Lint tools including RuboCop can report the warning instead of ruby


---Files--------------------------------
remove-shadowing-warning.patch (3.62 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>