literal regexp matches with named captures do not create local variables #2051

alex opened this Issue Nov 24, 2012 · 4 comments

3 participants



unknownc8bcc8a5a0c2:pypy alex_gaynor$ ruby-1.9.3-p125 -e "/(?<lhs>\d+)/ =~ '12'; puts lhs"
unknownc8bcc8a5a0c2:pypy alex_gaynor$ rbx-head -X19 -e "/(?<lhs>\d+)/ =~ '12'; puts lhs"
An exception occurred evaluating command line code
    undefined local variable or method `lhs' on an instance of Object. (NameError)

          Kernel(Object)#lhs (method_missing) at kernel/delta/kernel.rb:81
                     { } in Object#__script__ at -e:1
  Rubinius::BlockEnvironment#call_on_instance at kernel/common/block_environment.rb:75
                Kernel(Rubinius::Loader)#eval at kernel/common/eval.rb:75
                       Rubinius::Loader#evals at kernel/loader.rb:583
                        Rubinius::Loader#main at kernel/loader.rb:814

This is documented here:

Rubinius member

Why don't you file issues for easy things. :)


@brixen Next time I'll file out about regexp and encodings :(

Rubinius member

@alex oh, you want to play like that, huh? :)


+1 for compatibility with Ruby 1.9.1.

@dbussink dbussink added a commit that closed this issue Jul 21, 2013
@dbussink dbussink Setup locals from Regexp =~
Fixes #2051 and #2466
@dbussink dbussink closed this in 107c4c2 Jul 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment