Skip Menu |
Report information
Id: 114684
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: pmichaud <pmichaud [at] pobox.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [BUG] Return type mismatch should return Failure, not throw exception
Date: Fri, 31 Aug 2012 14:36:23 -0500
To: rakudobug [...] perl.org
From: "Patrick R. Michaud" <pmichaud [...] pobox.com>
Download (untitled) / with headers
text/plain 693b
19:34 <pmichaud> r: sub abc() returns Int { my $r = 3.5; $r }; my $x = abc(); say 'alive'; 19:34 <p6eval> rakudo 231137: OUTPUT«Type check failed for return value; expected 'Int' but got 'Rat'␤ in sub abc at /tmp/P8uacuh4gB:1␤ in block at /tmp/P8uacuh4gB:1␤␤» According to S02:1363, a return value not matching a constraint should internally call C<fail>, which means the above shouldn't die immediately. jnthn++ notes that this may be a deviation from the way type constraints are handled by other parts of the spec; thus the spec may want changing. If so, we can file a spec issue for that; in the meantime I'm filing the rakudobug so it doesn't get forgotten. Pm
Download (untitled) / with headers
text/plain 817b
On Fri, 31 Aug 2012 12:36:48 -0700, pmichaud wrote: Show quoted text
> 19:34 <pmichaud> r: sub abc() returns Int { my $r = 3.5; $r }; my > $x = abc(); say 'alive'; > 19:34 <p6eval> rakudo 231137: OUTPUT«Type check failed for return > value; expected 'Int' but got 'Rat'␤ in sub abc at /tmp/P8uacuh4gB:1␤ > in block at /tmp/P8uacuh4gB:1␤␤»
Still the same in current Rakudo: This is Rakudo version 2017.08-104-g76f1d8970 built on MoarVM version 2017.08.1-148-g1059eed1 implementing Perl 6.c. Better test-case: ➜ sub abc() returns Int { 3.5 }; say abc.defined; Type check failed for return value; expected Int but got Rat (3.5) Since there has been no update on this, and no-one's complaining about the current behavior, does this mean the ticket should be rejected? (Marking it RFC for now.)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org