Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InternalCompilerError: undefined method `compatible?' for nil:NilClass #157

Closed
abscondment opened this issue Dec 14, 2011 · 6 comments
Closed
Assignees

Comments

@abscondment
Copy link
Contributor

Updating my project to 0.0.10 from 0.0.9 showed a new compilation snag:

Mirah::InternalCompilerError: undefined method `compatible?' for nil:NilClass
         infer at /Users/brendan/code/mirah/lib/mirah/typer/simple.rb:280
         infer at /Users/brendan/code/mirah/lib/mirah/ast/flow.rb:376
    resolve_if at /Users/brendan/code/mirah/lib/mirah/ast.rb:248
         infer at /Users/brendan/code/mirah/lib/mirah/ast/flow.rb:374
         infer at /Users/brendan/code/mirah/lib/mirah/typer/simple.rb:275
         infer at /Users/brendan/code/mirah/lib/mirah/ast/structure.rb:34
          each at org/jruby/RubyArray.java:1614

Git bisect between 0.0.9 and 0.0.10 pins it on 677e4aa

I don't quite grok what's going on here, but I have a test case to help in fixing things: https://gist.github.com/1478479

@ghost ghost assigned baroquebobcat Dec 14, 2011
@abscondment
Copy link
Contributor Author

Interestingly, if I tweak the return value/type of that while block, this error goes away.

@abscondment
Copy link
Contributor Author

A more succinct test case:

class ContentType
  def getContentLength:long
    begin
      return getLengthOfParts
    rescue Exception => e
      return long(0)
    end
  end

  def getLengthOfParts:long
    long(1)
  end
end

@baroquebobcat
Copy link
Member

Funnily, these are actually two separate bugs. The first one is because we do inference on ensure as though it is an expression, even though ensure's never have a return type.

https://github.com/mirah/mirah/blob/master/lib/mirah/ast/flow.rb#L373-377

    class Ensure < Node
      child :body
      child :clause
      attr_accessor :state  # Used by some compilers.

      def initialize(parent, position, &block)
        super(parent, position, &block)
      end

      def infer(typer, expression)
        resolve_if(typer) do
          typer.infer(clause, false)
          typer.infer(body, true) # << true should be false here
        end
      end
    end

The second will take a bit more to tease out, but I'm guessing it has something to do with return not having a type & it needing to be special cased.

@abscondment
Copy link
Contributor Author

What do you think of abscondment@2fddffe for the 2nd issue?

@baroquebobcat
Copy link
Member

looks ok to me, add some test cases in test/jvm/test_rescue.rb that cover the new cases and open a pull request.

@baroquebobcat
Copy link
Member

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants