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

Owner: Nobody
Requestors: gfldex <wenzel.peppmeyer [at] gmx.de>
spidermario [at] free.fr
Cc:
AdminCc:

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



Subject: [BUG] Variable return types cause an error
Date: Sun, 08 Apr 2012 17:01:40 +0200
To: rakudobug [...] perl.org
From: spider-mario <spidermario [...] free.fr>
Download (untitled) / with headers
text/plain 362b
With Rakudo 2012.03-53-g119fe3b (commit 119fe3b5b85fe680aa1a7ea29042a5714e63a402), the following code fails: sub id(Any ::T $x) returns T { $x } say id 42; with the following error message: Type check failed for return value in sub id at testcase.pl:1 in block <anon> at testcase.pl:5 ::T correctly contains Int, though.
Download testcase.pl
text/x-perl 49b

Message body is not shown because sender requested not to inline it.

RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 709b
On Sun Apr 08 08:03:22 2012, spidermario@free.fr wrote: Show quoted text
> With Rakudo 2012.03-53-g119fe3b (commit > 119fe3b5b85fe680aa1a7ea29042a5714e63a402), the following code fails: > > sub id(Any ::T $x) returns T { > $x > } > > say id 42; > > with the following error message: > > Type check failed for return value > in sub id at testcase.pl:1 > in block <anon> at testcase.pl:5 > > ::T correctly contains Int, though.
Current behavior: $ cat a.pm sub id(Any ::T $x) returns T { $x } say id 42; $ ./perl6 a.pm Cannot type check against type variable T in any type_check at src/gen/Metamodel.nqp:305 in sub id at a.pm:2 in block at a.pm:5 -- Will "Coke" Coleda
From: "Wenzel P. P. Peppmeyer" <wenzel.peppmeyer [...] gmx.de>
To: rakudobug [...] perl.org
Date: Mon, 18 Jan 2016 15:00:11 +0100 (CET)
Subject: type captures in return type is not resolved
Download (untitled) / with headers
text/plain 228b
sub foo(::T $t --> T){ T.new }; my Int $i = 42; foo($i); # OUTPUT«Type check failed for return value; expected T but got Int␤ in # sub foo at /tmp/HqdmxVFmny line 1␤ in block <unit> at /tmp/HqdmxVFmny # line 1␤␤»
Download (untitled) / with headers
text/plain 693b
Updated behavior: Though it should just work, now at least the error isn't LTA. Also, checked that it happens no matter which method you use to apply the return type. $ perl6 -e 'sub id(Any ::T $x) returns T { $x }; say id 42;' Type check failed for return value; expected T but got Int in sub id at -e line 1 in block <unit> at -e line 1 $ perl6 -e 'sub id(Any ::T $x --> T) { $x }; say id 42;' Type check failed for return value; expected T but got Int in sub id at -e line 1 in block <unit> at -e line 1 $ perl6 -e 'sub id(Any ::T $x) of T { $x }; say id 42;' Type check failed for return value; expected T but got Int in sub id at -e line 1 in block <unit> at -e line 1
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 650b
On Mon Jan 18 06:00:47 2016, gfldex wrote: Show quoted text
> sub foo(::T $t --> T){ T.new }; > my Int $i = 42; > foo($i); > > # OUTPUT«Type check failed for return value; expected T but got Int␤ in > # sub foo at /tmp/HqdmxVFmny line 1␤ in block <unit> at /tmp/HqdmxVFmny > # line 1␤␤»
As a status update: This looks somewhat worse now: $ ./perl6-m -e 'sub foo(::T $t --> T){ 45 }; my Int $i = 42; foo($i);' X::TypeCheck::Return exception produced no message in sub foo at -e line 1 in block <unit> at -e line 1 $ ./perl6-m --version This is Rakudo version 2016.10-104-gdb61aaa built on MoarVM version 2016.10-27-g196361f implementing Perl 6.c.


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