Skip to content

Several named capture warnings in date/format #3865

@headius

Description

@headius

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:

/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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions