#662 √ invalid
Brian Ford

Unable to compile empty if

Reported by Brian Ford | July 17th, 2008 @ 08:48 AM | in 0.11

The following code was recently committed to rubyspecs:

  it "does not evaluate body if expression is empty" do
    a = []
    if ()
      a << 123
    end
    a.should == []
  end

It causes the following exception in Rubinius:

euler:rubinius brian$ bin/mspec spec/ruby/1.8/language/if_spec.rb 
rubinius 0.9.0 (ruby 1.8.6 compatible) (a424ed86e) (07/16/2008) [i686-apple-darwin9.4.0]
Compilation error detected: if (Compiler::Node::If) takes 2 argument(s): passed [#<Compiler:newline>, nil] (wrong number of arguments (got 2, required 3))
   near ./spec/ruby/1.8/language/if_spec.rb:23

                Compiler::Node::If.create {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:105
                      Kernel(Class)#catch {} at kernel/core/throw_catch.rb:63
                        ThrownValue.register at kernel/core/throw_catch.rb:48
                         Kernel(Class)#catch at kernel/core/throw_catch.rb:67
                   Compiler::Node::If.create at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:95
                       Compiler#convert_sexp at ./spec/compiler/../../lib/compiler/compiler.rb:199
    Compiler::Node(Compiler::Node::Newline)#consume {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:131
                                  Array#each at kernel/core/array.rb:572
    Compiler::Node(Compiler::Node::Newline)#consume at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:129
             Compiler::Node::Newline#consume at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:440
           Compiler::Node::Newline.create {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:96
                      Kernel(Class)#catch {} at kernel/core/throw_catch.rb:63
                        ThrownValue.register at kernel/core/throw_catch.rb:48
                         Kernel(Class)#catch at kernel/core/throw_catch.rb:67
              Compiler::Node::Newline.create at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:95
                       Compiler#convert_sexp at ./spec/compiler/../../lib/compiler/compiler.rb:199
    Compiler::Node(Compiler::Node::Block)#consume {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:131
                                  Array#each at kernel/core/array.rb:572
    Compiler::Node(Compiler::Node::Block)#consume at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:129
             Compiler::Node::Block.create {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:96
                      Kernel(Class)#catch {} at kernel/core/throw_catch.rb:63
                        ThrownValue.register at kernel/core/throw_catch.rb:48
                         Kernel(Class)#catch at kernel/core/throw_catch.rb:67
                Compiler::Node::Block.create at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:95
                       Compiler#convert_sexp at ./spec/compiler/../../lib/compiler/compiler.rb:199
    Compiler::Node(Compiler::Node::Iter)#convert at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:120
             Compiler::Node::Iter#consume {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:2477
    Compiler::Node::ClosedScope(Compiler::Node::Script)#new_block_scope at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:238
             Compiler::Node::Iter#consume {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:2472
                                   Proc#call at kernel/core/proc.rb:76
                                Compiler#set at ./spec/compiler/../../lib/compiler/compiler.rb:232
    Compiler::Node(Compiler::Node::Iter)#set at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:149
                Compiler::Node::Iter#consume at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:2470
              Compiler::Node::Iter.create {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:96
                      Kernel(Class)#catch {} at kernel/core/throw_catch.rb:63
                        ThrownValue.register at kernel/core/throw_catch.rb:48
                         Kernel(Class)#catch at kernel/core/throw_catch.rb:67
                 Compiler::Node::Iter.create at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:95
                       Compiler#convert_sexp at ./spec/compiler/../../lib/compiler/compiler.rb:199
    Compiler::Node(Compiler::Node::Newline)#consume {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:131
                                  Array#each at kernel/core/array.rb:572
    Compiler::Node(Compiler::Node::Newline)#consume at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:129
             Compiler::Node::Newline#consume at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:440
           Compiler::Node::Newline.create {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:96
                      Kernel(Class)#catch {} at kernel/core/throw_catch.rb:63
                        ThrownValue.register at kernel/core/throw_catch.rb:48
                         Kernel(Class)#catch at kernel/core/throw_catch.rb:67
              Compiler::Node::Newline.create at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:95
                       Compiler#convert_sexp at ./spec/compiler/../../lib/compiler/compiler.rb:199
    Compiler::Node(Compiler::Node::Block)#consume {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:131
                                  Array#each at kernel/core/array.rb:572
    Compiler::Node(Compiler::Node::Block)#consume at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:129
             Compiler::Node::Block.create {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:96
                      Kernel(Class)#catch {} at kernel/core/throw_catch.rb:63
                        ThrownValue.register at kernel/core/throw_catch.rb:48
                         Kernel(Class)#catch at kernel/core/throw_catch.rb:67
                Compiler::Node::Block.create at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:95
                       Compiler#convert_sexp at ./spec/compiler/../../lib/compiler/compiler.rb:199
    Compiler::Node(Compiler::Node::Iter)#convert at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:120
             Compiler::Node::Iter#consume {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:2477
    Compiler::Node::ClosedScope(Compiler::Node::Script)#new_block_scope at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:238
             Compiler::Node::Iter#consume {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:2472
                                   Proc#call at kernel/core/proc.rb:76
                                Compiler#set at ./spec/compiler/../../lib/compiler/compiler.rb:232
    Compiler::Node(Compiler::Node::Iter)#set at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:149
                Compiler::Node::Iter#consume at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:2470
              Compiler::Node::Iter.create {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:96
                      Kernel(Class)#catch {} at kernel/core/throw_catch.rb:63
                        ThrownValue.register at kernel/core/throw_catch.rb:48
                         Kernel(Class)#catch at kernel/core/throw_catch.rb:67
                 Compiler::Node::Iter.create at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:95
                       Compiler#convert_sexp at ./spec/compiler/../../lib/compiler/compiler.rb:199
    Compiler::Node(Compiler::Node::Newline)#consume {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:131
                                  Array#each at kernel/core/array.rb:572
    Compiler::Node(Compiler::Node::Newline)#consume at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:129
             Compiler::Node::Newline#consume at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:440
           Compiler::Node::Newline.create {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:96
                      Kernel(Class)#catch {} at kernel/core/throw_catch.rb:63
                        ThrownValue.register at kernel/core/throw_catch.rb:48
                         Kernel(Class)#catch at kernel/core/throw_catch.rb:67
              Compiler::Node::Newline.create at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:95
                       Compiler#convert_sexp at ./spec/compiler/../../lib/compiler/compiler.rb:199
    Compiler::Node(Compiler::Node::Block)#consume {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:131
                                  Array#each at kernel/core/array.rb:572
    Compiler::Node(Compiler::Node::Block)#consume at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:129
             Compiler::Node::Block.create {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:96
                      Kernel(Class)#catch {} at kernel/core/throw_catch.rb:63
                        ThrownValue.register at kernel/core/throw_catch.rb:48
                         Kernel(Class)#catch at kernel/core/throw_catch.rb:67
                Compiler::Node::Block.create at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:95
                       Compiler#convert_sexp at ./spec/compiler/../../lib/compiler/compiler.rb:199
    Compiler::Node(Compiler::Node::Script)#convert at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:120
    Compiler::Node::ClosedScope(Compiler::Node::Script)#consume {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:219
                                   Proc#call at kernel/core/proc.rb:76
                                Compiler#set at ./spec/compiler/../../lib/compiler/compiler.rb:224
    Compiler::Node(Compiler::Node::Script)#set at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:149
    Compiler::Node::ClosedScope(Compiler::Node::Script)#consume at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:218
            Compiler::Node::Script.create {} at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:96
                      Kernel(Class)#catch {} at kernel/core/throw_catch.rb:63
                        ThrownValue.register at kernel/core/throw_catch.rb:48
                         Kernel(Class)#catch at kernel/core/throw_catch.rb:67
               Compiler::Node::Script.create at /Users/brian/devel/rubinius/lib/compiler/nodes.rb:95
                       Compiler#convert_sexp at ./spec/compiler/../../lib/compiler/compiler.rb:199
                        Compiler#into_script at ./spec/compiler/../../lib/compiler/compiler.rb:209
                       Compiler.compile_file at ./spec/compiler/../../lib/compiler/compiler.rb:21
                        Compile.compile_file at kernel/core/compile.rb:66
                      Compile.single_load {} at kernel/core/compile.rb:212
                     Compile.compile_feature at kernel/core/compile.rb:171
                         Compile.single_load at kernel/core/compile.rb:211
                     Compile.unified_load {} at kernel/core/compile.rb:160
                                  Array#each at kernel/core/array.rb:572
                        Compile.unified_load at kernel/core/compile.rb:127
                                 Kernel.load at kernel/core/compile.rb:408
                    #<Object:0x149>.files {} at /Users/brian/devel/rubinius/mspec/lib/mspec/runner/mspec.rb:54
                Kernel(Object)#instance_eval at kernel/core/eval.rb:103
                               MSpec.protect at /Users/brian/devel/rubinius/mspec/lib/mspec/runner/mspec.rb:66
                              MSpec.files {} at /Users/brian/devel/rubinius/mspec/lib/mspec/runner/mspec.rb:54
                                  Array#each at kernel/core/array.rb:572
                                 MSpec.files at /Users/brian/devel/rubinius/mspec/lib/mspec/runner/mspec.rb:48
                               MSpec.process at /Users/brian/devel/rubinius/mspec/lib/mspec/runner/mspec.rb:40
                                MSpecRun#run at /Users/brian/devel/rubinius/mspec/lib/mspec/commands/mspec-run.rb:75
                               MSpecRun.main at /Users/brian/devel/rubinius/mspec/lib/mspec/utils/script.rb:86
                           Object#__script__ at /Users/brian/devel/rubinius/mspec/bin/mspec-run:8
                    CompiledMethod#as_script at kernel/core/compiled_method.rb:407
                         Compile.single_load at kernel/core/compile.rb:248
                 Compile.load_from_extension at kernel/core/compile.rb:326
                           Object#__script__ at kernel/loader.rb:221


1)
An exception occurred during: loading spec/ruby/1.8/language/if_spec.rb ERROR
NoMethodError: No method 'to_description' on an instance of NilClass.
    Kernel(NilClass)#to_description (method_missing_cv) at kernel/core/kernel.rb:652
                       Compiler.compile_file at ./spec/compiler/../../lib/compiler/compiler.rb:22
                        Compile.compile_file at kernel/core/compile.rb:66
                      Compile.single_load {} at kernel/core/compile.rb:212
                     Compile.compile_feature at kernel/core/compile.rb:174
                         Compile.single_load at kernel/core/compile.rb:211
                     Compile.unified_load {} at kernel/core/compile.rb:160
                                  Array#each at kernel/core/array.rb:572
                        Compile.unified_load at kernel/core/compile.rb:127
                                 Kernel.load at kernel/core/compile.rb:408
                Kernel(Object)#instance_eval at kernel/core/eval.rb:103
                                  Array#each at kernel/core/array.rb:572
                    CompiledMethod#as_script at kernel/core/compiled_method.rb:407
                         Compile.single_load at kernel/core/compile.rb:248
                 Compile.load_from_extension at kernel/core/compile.rb:326
                           Object#__script__ at kernel/loader.rb:221

Finished in 0.037885 seconds

1 file, 0 examples, 0 expectations, 0 failures, 1 error

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Tags