You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ideally none of the standard library sources should produce warnings in verbose mode.
Actual Behavior
Our date/format.rb, created by @eregon, produces the following errors when loaded in verbose mode:
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:960: warning: named capture conflicts a local variable - year
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:960: warning: named capture conflicts a local variable - mon
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:960: warning: named capture conflicts a local variable - mday
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:960: warning: named capture conflicts a local variable - yday
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:960: warning: named capture conflicts a local variable - cwyear
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:960: warning: named capture conflicts a local variable - cweek
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:960: warning: named capture conflicts a local variable - cwday
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:960: warning: named capture conflicts a local variable - hour
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:960: warning: named capture conflicts a local variable - min
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:960: warning: named capture conflicts a local variable - sec
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:960: warning: named capture conflicts a local variable - sec_fraction
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:960: warning: named capture conflicts a local variable - zone
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:1005: warning: named capture conflicts a local variable - hour
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:1005: warning: named capture conflicts a local variable - min
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:1005: warning: named capture conflicts a local variable - sec
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:1005: warning: named capture conflicts a local variable - sec_fraction
/Users/headius/projects/jruby/lib/ruby/stdlib/date/format.rb:1005: warning: named capture conflicts a local variable - zone
These errors are Ruby's attempt to warn us that we're using the same local variable name as a named capture. I do not believe this warning is useful, and I have filed https://bugs.ruby-lang.org/issues/12359 to have it removed from Ruby. If that bug is not accepted, we'll need to change this code to eliminate the warnings.
The text was updated successfully, but these errors were encountered:
One way to avoid it would be to put each branch in a different scope, either blocks or methods. But that probably has some overhead.
Do we want to keep the exact same warnings as MRI, even on stdlib code? Otherwise that warning could be disabled for that known file (yes it's a hack, but are the other workarounds better?).
Thanks for filing the MRI issue!
Yeah, that's another way to fix it. I'd rather we just remove the warning altogether, though, since I think the only options for users to remove it are all gross. We'll see what ruby-core thinks.
For now I've fixed our issues by modifying the warning to only fire when a named capture has already been declared as a non-named-capture. I'll follow up with ruby-core on the remaining issue.
Environment
JRuby 9k versions through 9.1.
Expected Behavior
Ideally none of the standard library sources should produce warnings in verbose mode.
Actual Behavior
Our date/format.rb, created by @eregon, produces the following errors when loaded in verbose mode:
These errors are Ruby's attempt to warn us that we're using the same local variable name as a named capture. I do not believe this warning is useful, and I have filed https://bugs.ruby-lang.org/issues/12359 to have it removed from Ruby. If that bug is not accepted, we'll need to change this code to eliminate the warnings.
The text was updated successfully, but these errors were encountered: