Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Rubinius fails to parse certain block invocations #1917

Closed
alex opened this Issue · 3 comments

3 participants

@alex

The code to reproduce is:

return [].inject 0 do
end

Note that this also fails to parse under Jruby (FWIW):

alex@alex-gaynor-laptop:/tmp$ cat t.rb 
return [].inject 0 do
end

alex@alex-gaynor-laptop:/tmp$ ruby-1.9.3-p125 t.rb 
t.rb:1:in `<main>': unexpected return (LocalJumpError)
alex@alex-gaynor-laptop:/tmp$ jruby-1.6.7.2 --1.9 t.rb 
SyntaxError: t.rb:1: syntax error, unexpected kDO_BLOCK

return [].inject 0 do
^
alex@alex-gaynor-laptop:/tmp$ rbx-head -X19 t.rb 
An exception occurred running t.rb
    Error trying to compile /tmp/t.rb (Rubinius::CompileError)

Backtrace:
  Rubinius::Compiler.compiler_error at /home/alex/.rvm/rubies/rbx-head/runtime/19/compiler/compiler.rbc:13
         Rubinius::Compiler.compile at /home/alex/.rvm/rubies/rbx-head/runtime/19/compiler/compiler.rbc:92
  Rubinius::CodeLoader#compile_file at kernel/delta/codeloader.rb:166
     Rubinius::CodeLoader#load_file at kernel/delta/codeloader.rb:138
   Rubinius::CodeLoader#load_script at kernel/delta/codeloader.rb:63
   Rubinius::CodeLoader.load_script at kernel/delta/codeloader.rb:109
            Rubinius::Loader#script at kernel/loader.rb:640
              Rubinius::Loader#main at kernel/loader.rb:844

Caused by: undefined method `block=' on an instance of Rubinius::AST::Return. (NoMethodError)

Backtrace:
   Kernel(Rubinius::AST::Return)#block= (method_missing) at kernel/delta/kernel.rb:81
                     Rubinius::Melbourne19#process_iter at /home/alex/.rvm/rubies/rbx-head/runtime/19/melbourne
                                                           /processor.rbc:550
 Rubinius::Melbourne(Rubinius::Melbourne19)#file_to_ast_19 at /home/alex/.rvm/src/rbx-head/lib/ext/melbourne
                                                              /melbourne.cpp
   Rubinius::Melbourne(Rubinius::Melbourne19)#parse_file at /home/alex/.rvm/rubies/rbx-head/runtime/19/melbourne.rbc:84
                   Rubinius::Compiler::FileParser#parse at /home/alex/.rvm/rubies/rbx-head/runtime/19/compiler
                                                           /stages.rbc:235
 Rubinius::Compiler::Parser(Rubinius::Compiler::FileParser)#run at /home/alex/.rvm/rubies/rbx-head/runtime/19/compiler
                                                                   /stages.rbc:217
                                 Rubinius::Compiler#run at /home/alex/.rvm/rubies/rbx-head/runtime/19/compiler
                                                           /compiler.rbc:374
                             Rubinius::Compiler.compile at /home/alex/.rvm/rubies/rbx-head/runtime/19/compiler
                                                           /compiler.rbc:88
                       Rubinius::CodeLoader#compile_file at kernel/delta/codeloader.rb:166
                          Rubinius::CodeLoader#load_file at kernel/delta/codeloader.rb:138
                        Rubinius::CodeLoader#load_script at kernel/delta/codeloader.rb:63
                        Rubinius::CodeLoader.load_script at kernel/delta/codeloader.rb:109
                                 Rubinius::Loader#script at kernel/loader.rb:640
                                   Rubinius::Loader#main at kernel/loader.rb:844

@alex

Managed to simplify the test case slightly

return f 0 do
end
@alex

For reference, the Jruby issue is #305

@frodsan

This is still an issue on master:

$ rbx t.rb 
An exception occurred running t.rb
    Error trying to compile /Users/frodsan/tmp/rubinius/t.rb (Rubinius::CompileError)

Backtrace:
  Rubinius::Compiler.compiler_error at /Users/frodsan/.rbenv/versions/rbx-2.0.0-dev/runtime/19/compiler/compiler.rbc:13
         Rubinius::Compiler.compile at /Users/frodsan/.rbenv/versions/rbx-2.0.0-dev/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:155
   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:614
              Rubinius::Loader#main at kernel/loader.rb:815

Caused by: undefined method `block=' on an instance of Rubinius::AST::Return. (NoMethodError)

Backtrace:
           Kernel(Rubinius::AST::Return)#block= (method_missing) at kernel/delta/kernel.rb:81
                              Rubinius::Melbourne19#process_iter at /Users/frodsan/.rbenv/versions/rbx-2.0.0-dev/runtime/19/melbourne/processor.rbc:550
       Rubinius::Melbourne(Rubinius::Melbourne19)#file_to_ast_19 at /Users/frodsan/Code/rubinius/staging/lib/ext/melbourne/melbourne.cpp
           Rubinius::Melbourne(Rubinius::Melbourne19)#parse_file at /Users/frodsan/.rbenv/versions/rbx-2.0.0-dev/runtime/19/melbourne.rbc:97
                            Rubinius::Compiler::FileParser#parse at /Users/frodsan/.rbenv/versions/rbx-2.0.0-dev/runtime/19/compiler/stages.rbc:225
  Rubinius::Compiler::Parser(Rubinius::Compiler::FileParser)#run at /Users/frodsan/.rbenv/versions/rbx-2.0.0-dev/runtime/19/compiler/stages.rbc:207
                                          Rubinius::Compiler#run at /Users/frodsan/.rbenv/versions/rbx-2.0.0-dev/runtime/19/compiler/compiler.rbc:374
                                      Rubinius::Compiler.compile at /Users/frodsan/.rbenv/versions/rbx-2.0.0-dev/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:155
                                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:614
                                           Rubinius::Loader#main at kernel/loader.rb:815
@skliew skliew referenced this issue from a commit
@skliew skliew Add spec for issue #1917 c142d08
@skliew skliew referenced this issue from a commit
@skliew skliew Fix issue #1917 1a295be
@dbussink dbussink closed this
@brixen brixen referenced this issue from a commit in rubinius/rubinius-ast
@brixen brixen Fixed break, next with method.
This was fixed for return in rubinius/rubinius#1917
830a9f1
@brixen brixen referenced this issue from a commit
@brixen brixen Added specs for break, next with method.
This was fixed for return in #1917
bcabb12
@whitequark whitequark referenced this issue in seattlerb/ruby_parser
Closed

Return takes a block #140

@brixen brixen referenced this issue from a commit in rubyspec/rubyspec
@brixen brixen Added specs for break, next with method.
This was fixed for return in rubinius/rubinius#1917
bbb072b
@euank euank referenced this issue from a commit in euank/moebooru-thin
@nanaya nanaya The return style chokes rbx and jruby. b8f15f9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.