#660 new
nexcastellan

Compile error with empty expressions

Reported by nexcastellan | July 16th, 2008 @ 12:50 PM | in 1.0 preview

This is spec'ed as rubyspec commit 880d54b41cbfd8815fa197fa28776d5dc0361efe

The following statement fails in Rubinius, but not in MRI:

if () then end

We get a compile error:

ArgumentError: if (Compiler::Node::If) takes 2 argument(s): passed [nil, nil] (wrong number of arguments (got 2, required 3))
   from Compiler::Node::If.create {} at lib/compiler/nodes.rb:105
   from Kernel(Class)#catch {} at kernel/core/throw_catch.rb:63
   from ThrownValue.register at kernel/core/throw_catch.rb:48
   from Kernel(Class)#catch at kernel/core/throw_catch.rb:67
   from Compiler::Node::If.create at lib/compiler/nodes.rb:95
   from Compiler#convert_sexp at lib/compiler/compiler.rb:199
   from Compiler::Node(Compiler::Node::Newline)#consume {} at lib/compiler/nodes.rb:131
   from Array#each at kernel/core/array.rb:572
   from Compiler::Node(Compiler::Node::Newline)#consume at lib/compiler/nodes.rb:129
   from Compiler::Node::Newline#consume at lib/compiler/nodes.rb:440
   from Compiler::Node::Newline.create {} at lib/compiler/nodes.rb:96
   from Kernel(Class)#catch {} at kernel/core/throw_catch.rb:63
   from ThrownValue.register at kernel/core/throw_catch.rb:48
   from Kernel(Class)#catch at kernel/core/throw_catch.rb:67
   from Compiler::Node::Newline.create at lib/compiler/nodes.rb:95
   from Compiler#convert_sexp at lib/compiler/compiler.rb:199
   from Compiler::Node(Compiler::Node::EvalExpression)#convert at lib/compiler/nodes.rb:120
   from Compiler::Node::ClosedScope(Compiler::Node::EvalExpression)#consume {} at lib/compiler/nodes.rb:219
   from Proc#call at kernel/core/proc.rb:76
   from Compiler#set at lib/compiler/compiler.rb:224
   from Compiler::Node(Compiler::Node::EvalExpression)#set at lib/compiler/nodes.rb:149
   from Compiler::Node::ClosedScope(Compiler::Node::EvalExpression)#consume at lib/compiler/nodes.rb:218
   from Compiler::Node::Snippit(Compiler::Node::EvalExpression)#consume {} at lib/compiler/nodes.rb:340
   from Proc#call at kernel/core/proc.rb:76
   from Compiler#set at lib/compiler/compiler.rb:232
   from Compiler::Node(Compiler::Node::EvalExpression)#set at lib/compiler/nodes.rb:149
   from Compiler::Node::Snippit(Compiler::Node::EvalExpression)#consume at lib/compiler/nodes.rb:339
   from Compiler::Node::EvalExpression#consume at lib/compiler/nodes.rb:364
   from Compiler::Node::EvalExpression.create {} at lib/compiler/nodes.rb:96
   from Kernel(Class)#catch {} at kernel/core/throw_catch.rb:63
   from ThrownValue.register at kernel/core/throw_catch.rb:48
   from Kernel(Class)#catch at kernel/core/throw_catch.rb:67
   from Compiler::Node::EvalExpression.create at lib/compiler/nodes.rb:95
   from Compiler#convert_sexp at lib/compiler/compiler.rb:199
   from Compiler.compile_string at lib/compiler/compiler.rb:30
   from Compile.compile_string at kernel/core/compile.rb:70

Comments and changes to this ticket

  • seydar

    seydar July 17th, 2008 @ 09:35 AM

    looks like the compiler, grammar_runtime.c, is the culprit.

  • seydar

    seydar July 17th, 2008 @ 09:44 AM

    line 248 of grammar_runtime.c i think starts the problem. some printf's should tell.

  • Evan Phoenix

    Evan Phoenix July 17th, 2008 @ 10:01 AM

    Well, yes and no. Typically, it's the compiler that needs to do deal with all forms of sexp. The only place where I consider it a grammar_runtime bug is if the sexp is ambigious, which doesn't seem to be the case here.

    So we just need to make compiler/nodes.rb aware of this. The biggest reason to fix this in grammar_runtime is so that we don't have to fix a million places in nodes.rb to deal with a potentially missing sexp argument.

  • seydar

    seydar July 17th, 2008 @ 01:00 PM

    Am I being naive by thinking that "()" is mistakenly not getting

    parsed as something it should be? If it wasn't getting parsed as

    anything, then there would be a syntax error. But there isn't a

    syntax error, which tells me that its getting parsed as *something*,

    just not the right something. I checked nodes.rb, and it was just,

    to me, objects with which to fill in the syntax tree. But the syntax

    tree itself is incorrect, so I assumed it was an issue in the parsing

    itself.

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