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

Rakudo does not enforce return type constraints for implicit returns #2514

Closed
p6rt opened this issue Oct 14, 2011 · 5 comments
Closed

Rakudo does not enforce return type constraints for implicit returns #2514

p6rt opened this issue Oct 14, 2011 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Oct 14, 2011

Migrated from rt.perl.org#101364 (status was 'resolved')

Searchable as RT101364$

@p6rt
Copy link
Author

p6rt commented Oct 14, 2011

From @moritz

Found by mls.

16​:45 < moritz> nom​: sub foo returns Int { Mu } ; say foo()
16​:45 <+p6eval> nom ce15be​: OUTPUT«Mu()␤»
16​:46 < jnthn> moritz​: yeah, bug...please file ticket

Note that it complains if you use an explicit return​:

16​:41 < mls_> perl6​: sub foo returns Int { return Mu } ; say foo()
16​:41 <+p6eval> ..rakudo ce15be​: OUTPUT«Type check failed for return
value␤ in sub foo at /tmp/Z7ulfnjlGl​:1␤ in block <anon> at
  /tmp/Z7ulfnjlGl​:1␤ in <anon> at /tmp/Z7ulfnjlGl​:1␤»

@p6rt
Copy link
Author

p6rt commented Oct 19, 2011

From @jnthn

On Fri Oct 14 07​:48​:40 2011, moritz wrote​:

Found by mls.

16​:45 < moritz> nom​: sub foo returns Int { Mu } ; say foo()
16​:45 <+p6eval> nom ce15be​: OUTPUT«Mu()␤»
16​:46 < jnthn> moritz​: yeah, bug...please file ticket

Note that it complains if you use an explicit return​:

16​:41 < mls_> perl6​: sub foo returns Int { return Mu } ; say foo()
16​:41 <+p6eval> ..rakudo ce15be​: OUTPUT«Type check failed for return
value␤ in sub foo at /tmp/Z7ulfnjlGl​:1␤ in block <anon> at
/tmp/Z7ulfnjlGl​:1␤ in <anon> at /tmp/Z7ulfnjlGl​:1␤»

Fixed​:

sub foo returns Int { Mu } ; say foo()
Type check failed for return value

Needs test.

/jnthn

@p6rt
Copy link
Author

p6rt commented Oct 19, 2011

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Apr 5, 2012

From @moritz

Tested in S02-types/type.t.

Note that these two forms still don't check the return type​:

my Int sub foo { }
sub foo( --> Int) { }

@p6rt
Copy link
Author

p6rt commented Apr 5, 2012

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Apr 5, 2012
@p6rt p6rt added the testneeded label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant