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 59: inferred type appears wrong? #108

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

Issue 59: inferred type appears wrong? #108

consiliens opened this issue Aug 26, 2011 · 3 comments
Assignees

Comments

@consiliens
Copy link
Contributor

@consiliens consiliens commented Aug 26, 2011

"
Reported by rogerpack2005, May 28, 2011
As described
http://groups.google.com/group/mirah/browse_thread/thread/ea8b610c2771df4a

interface MyInterface do
def run():int; end
end

def go(block:MyInterface)
block.run()
end

a = 3
go { b = 4 }

I think should work, but doesn't.

$ mirah yoyo.mr
Inference Error:
yoyo.mr:11: Inferred return type Type(void) is incompatible with declared Type(int)
go { b = 4 }

it should be inferring return type int, I think.

Other incantations that I "think" should work but don't (possibly related):

interface MyInterface do
def run(a:int):int; end
end

def go(block:MyInterface)
block.run(3)
end

a = 3
go { b = 4 }

(same error)

and

interface MyInterface do
def run(a:int):int; end
end

def go(block:MyInterface)
block.run(3)
end
a = 3
go {|n| a = 4}

...
yoyo.mr:10:in `main': java.lang.VerifyError: (class: Yoyo/mr$__xform_tmp_2, method: run signature: (I)I) Unable to pop operand off an empty stack

v0.0.7


Comment 1 by rogerpack2005, May 28, 2011
actually the first example works now, the rest still fail


Comment 2 by rogerpack2005, May 30, 2011
maybe related to #37 ?
"
http://code.google.com/p/mirah/issues/detail?id=59

@ghost ghost assigned baroquebobcat Oct 16, 2011
@baroquebobcat
Copy link
Member

@baroquebobcat baroquebobcat commented Oct 18, 2011

Reproduced. When you create a block that has a different signature than the interface it's supposed to be implementing, we don't complain and generate invalid code.

interface MyInterface do
def run(a:int):int; end
end

def go(block:MyInterface)
block.run(3)
end

go { b = 4 } #the closure class here has a #run() method not #run(int x)
@baroquebobcat
Copy link
Member

@baroquebobcat baroquebobcat commented Oct 25, 2011

Would you expect an error, or if you really don't care would you like the generated code to act as if you are ignoring the arguments?

I can see cases where the later could make things clearer--but it might not be the nicest thing.

what does JRuby do in this situation?

@baroquebobcat
Copy link
Member

@baroquebobcat baroquebobcat commented Jan 10, 2012

this is actually a dup of #69. Closing.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.