Issue 59: inferred type appears wrong? #108

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

Comments

Projects
None yet
2 participants
@consiliens
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@baroquebobcat

baroquebobcat Oct 18, 2011

Member

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)
Member

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

This comment has been minimized.

Show comment
Hide comment
@baroquebobcat

baroquebobcat Oct 25, 2011

Member

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?

Member

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

This comment has been minimized.

Show comment
Hide comment
@baroquebobcat

baroquebobcat Jan 10, 2012

Member

this is actually a dup of #69. Closing.

Member

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