Compilation error on pattern matching with * variable #2073

Closed
sheerun opened this Issue Dec 3, 2012 · 4 comments

Projects

None yet

2 participants

@sheerun
sheerun commented Dec 3, 2012
2.times { |(v, (*))| }
An exception occurred running t.rb (Rubinius::CompileError)

Backtrace:
  Rubinius::Compiler.compiler_error at /Users/sheerun/Projects/rubinius/runtime/19/compiler/compiler.rbc:13
         Rubinius::Compiler.compile at /Users/sheerun/Projects/rubinius/runtime/19/compiler/compiler.rbc:92
  Rubinius::CodeLoader#compile_file at kernel/delta/codeloader.rb:181
     Rubinius::CodeLoader#load_file at kernel/delta/codeloader.rb:150
   Rubinius::CodeLoader#load_script at kernel/delta/codeloader.rb:64
   Rubinius::CodeLoader.load_script at kernel/delta/codeloader.rb:118
            Rubinius::Loader#script at kernel/loader.rb:615
              Rubinius::Loader#main at kernel/loader.rb:816

Caused by: undefined method `body' on nil:NilClass. (NoMethodError)

Backtrace:
                          Kernel(NilClass)#body (method_missing) at kernel/delta/kernel.rb:81
                      Rubinius::AST::PatternArguments.from_masgn at /Users/sheerun/Projects/rubinius/runtime/19/compiler/ast/definitions.rbc:527
               { } in Rubinius::AST::PatternArguments.from_masgn at /Users/sheerun/Projects/rubinius/runtime/19/compiler/ast/definitions.rbc:530
                                                       Array#map at kernel/bootstrap/array19.rb:18
                      Rubinius::AST::PatternArguments.from_masgn at /Users/sheerun/Projects/rubinius/runtime/19/compiler/ast/definitions.rbc:527
              { } in Rubinius::AST::FormalArguments19#initialize at /Users/sheerun/Projects/rubinius/runtime/19/compiler/ast/definitions.rbc:424
                                                      Array#each at kernel/bootstrap/array.rb:68
                     Rubinius::AST::FormalArguments19#initialize at /Users/sheerun/Projects/rubinius/runtime/19/compiler/ast/definitions.rbc:418
                              Rubinius::Melbourne19#process_args at /Users/sheerun/Projects/rubinius/runtime/19/melbourne/processor.rbc:510
       Rubinius::Melbourne(Rubinius::Melbourne19)#file_to_ast_19 at /Users/sheerun/Projects/rubinius/lib/ext/melbourne/melbourne.cpp
           Rubinius::Melbourne(Rubinius::Melbourne19)#parse_file at /Users/sheerun/Projects/rubinius/runtime/19/melbourne.rbc:97
                            Rubinius::Compiler::FileParser#parse at /Users/sheerun/Projects/rubinius/runtime/19/compiler/stages.rbc:225
  Rubinius::Compiler::Parser(Rubinius::Compiler::FileParser)#run at /Users/sheerun/Projects/rubinius/runtime/19/compiler/stages.rbc:207
                                          Rubinius::Compiler#run at /Users/sheerun/Projects/rubinius/runtime/19/compiler/compiler.rbc:374
                                      Rubinius::Compiler.compile at /Users/sheerun/Projects/rubinius/runtime/19/compiler/compiler.rbc:88
                               Rubinius::CodeLoader#compile_file at kernel/delta/codeloader.rb:181
                                  Rubinius::CodeLoader#load_file at kernel/delta/codeloader.rb:150
                                Rubinius::CodeLoader#load_script at kernel/delta/codeloader.rb:64
                                Rubinius::CodeLoader.load_script at kernel/delta/codeloader.rb:118
                                         Rubinius::Loader#script at kernel/loader.rb:615
                                           Rubinius::Loader#main at kernel/loader.rb:816
@Peeja
Peeja commented Dec 9, 2012

I'm curious: why would you use

2.times { |(v, (*))| }

instead of simply

2.times { |(v, *)| }

(which does parse, and would seem to mean the same thing)?

@sheerun
sheerun commented Dec 9, 2012

It's not my code. I took it from Matz's mruby tests.

@Peeja
Peeja commented Dec 9, 2012

@sheerun Ah, interesting, can you link to that test?

@sheerun
sheerun commented Dec 9, 2012

Sure. Here you have:
https://github.com/mruby/mruby/blob/master/test/t/bs_block.rb#L332

On Sun, Dec 9, 2012 at 11:14 PM, Peter Jaros notifications@github.comwrote:

@sheerun https://github.com/sheerun Ah, interesting, can you link to
that test?


Reply to this email directly or view it on GitHubhttps://github.com/rubinius/rubinius/issues/2073#issuecomment-11176883.

@dbussink dbussink added a commit that closed this issue Jul 29, 2013
@dbussink dbussink Fix pattern matching specs with post splat arguments
This handles pattern matching for post splat block arguments.

Fixes #1569, fixes #2073, fixes #2094, fixes #1777
2ab0d14
@dbussink dbussink closed this in 2ab0d14 Jul 29, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment