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

Issue 79: Mirah::InternalCompilerError: No constructor #128

Closed
consiliens opened this issue Aug 26, 2011 · 5 comments
Closed

Issue 79: Mirah::InternalCompilerError: No constructor #128

consiliens opened this issue Aug 26, 2011 · 5 comments
Milestone

Comments

@consiliens
Copy link
Contributor

"
Reported by rogerpack2005, Jun 3, 2011
this java:

import java.util.ArrayList; 
class yo extends ArrayList { 
   yo(java.util.List o) { 
    super(); 
   } 
} 

compiles, but this mirah:

import java.util.ArrayList 
class A < ArrayList 
   def initialize(o:java.util.List) 
    super 
   end 
end 

does not:
...
Mirah::InternalCompilerError: No constructor
java.util.ArrayList(Type(java.util.List))

ref: http://groups.google.com/group/mirah/browse_thread/thread/dfd77751fc0902c5
"

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

@baroquebobcat
Copy link
Member

@rdp, what would you expect super to do in

import java.util.ArrayList 
class A < ArrayList 
   def initialize(o:java.util.List) 
    super 
   end 
end 

call ArrayList()?

Also, if it were

import java.util.ArrayList 
class A < ArrayList 
   def initialize(o:java.util.List) 
    super o 
   end 
end 

Would that call ArrayList(Collection c)?

@rdp
Copy link
Contributor

rdp commented Aug 31, 2011

I think so, isn't that what it does in java?

@baroquebobcat
Copy link
Member

I get NameError: No constructor java.util.ArrayList(#<Type java.util.List>) with master. Also, it appears that fully qualified param typing is a syntax error right now.

The basic problem is that somewhere we are not widening the argument to super.

@baroquebobcat
Copy link
Member

This is using Ruby semantics for initialization super delegation. In Ruby,

  def initialize x
    super
   end

means call super with my args. You have to change how you use super to make it more specific

You can have the behavior you expect by doing

  def initialize o: List
    super()
   end

You could also do

  def initialize o: List
    super o.size
   end

Also, it appears that fully qualified param typing is a syntax error right now.

Yeah, I'm not entirely sure why that is. Maybe something changed to require double colons instead of periods as a package separator.

@baroquebobcat
Copy link
Member

I'm closing this. After reading more of the implementation this looks like intended behavior. I've added some more tests to better specify it.

baroquebobcat added a commit that referenced this issue Aug 4, 2013
Mirah's super acts like Ruby's--which has some quirks. #128
baroquebobcat added a commit that referenced this issue Aug 28, 2013
Mirah's super acts like Ruby's--which has some quirks. #128
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

3 participants