Issue 61: ICE with an empty block #110

Closed
consiliens opened this Issue Aug 26, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@consiliens
Contributor

consiliens commented Aug 26, 2011

"
Reported by rogerpack2005, May 28, 2011
Run the following code:

import java.util.ArrayList

interface CallableOneArg do
  def call(arg1:Object):Object
  end
end

# should I make this class static? cache it [in a hash]?
class RubyInt < Object

  def times(call_me:CallableOneArg):Object
    self
  end

end

RubyInt.new.times do |n|

end

=> Mirah::InternalCompilerError: undefined method `each' for nil:NilClass

"

http://code.google.com/p/mirah/issues/detail?id=61

@ghost ghost assigned baroquebobcat Oct 16, 2011

@baroquebobcat

This comment has been minimized.

Show comment
Hide comment
@baroquebobcat

baroquebobcat Oct 16, 2011

Member

reproduced and looking into it.

Member

baroquebobcat commented Oct 16, 2011

reproduced and looking into it.

@baroquebobcat

This comment has been minimized.

Show comment
Hide comment
@baroquebobcat

baroquebobcat Oct 16, 2011

Member

0a826dd fixes this.

The problem was that a Block with an empty body was being transformed into an AST node with a nil body.
The typer then checks the body to see if it contains any method definitions and if it does it appends them to the class representing the block.

The code was blowing up where it checked for children of the body because the body was nil. Now the body will be an AST node with no children.

Member

baroquebobcat commented Oct 16, 2011

0a826dd fixes this.

The problem was that a Block with an empty body was being transformed into an AST node with a nil body.
The typer then checks the body to see if it contains any method definitions and if it does it appends them to the class representing the block.

The code was blowing up where it checked for children of the body because the body was nil. Now the body will be an AST node with no children.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment