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

Owner: Nobody
Requestors: zefram [at] fysh.org
Cc:
AdminCc:

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



To: rakudobug [...] perl.org
From: Zefram <zefram [...] fysh.org>
Date: Sat, 19 Sep 2015 19:15:18 +0100
Subject: [BUG] coercive type constraint for variable inconsistently accepted
Download (untitled) / with headers
text/plain 650b
A coercive type constraint is not permitted on a variable: $ ./perl6 -e 'my Int() $a; say 1' ===SORRY!=== Error while compiling -e Coercion Int(Any) is insufficiently type-like to qualify a variable at -e:1 ------> my Int() $a^; say 1 expecting any of: constraint But it *is* accepted if expressed in "of" form: $ ./perl6 -e 'my $a of Int(); say 1' 1 But it doesn't actually work: $ ./perl6 -e 'my $a of Int(); $a = 3; say $a' Type check failed in assignment to '$a'; expected 'Int(Any)' but got 'Int' in block <unit> at -e:1 Presumably it should be forbidden in the "of" form just as it is forbidden in the prefix form. -zefram
Still reproducible (2017.11,HEAD(e5b660e))

On 2015-09-19 11:15:43, zefram@fysh.org wrote:
Show quoted text
> A coercive type constraint is not permitted on a variable:
>
> $ ./perl6 -e 'my Int() $a; say 1'
> ===SORRY!=== Error while compiling -e
> Coercion Int(Any) is insufficiently type-like to qualify a variable
> at -e:1
> ------> my Int() $a^; say 1
> expecting any of:
> constraint
>
> But it *is* accepted if expressed in "of" form:
>
> $ ./perl6 -e 'my $a of Int(); say 1'
> 1
>
> But it doesn't actually work:
>
> $ ./perl6 -e 'my $a of Int(); $a = 3; say $a'
> Type check failed in assignment to '$a'; expected 'Int(Any)' but got 'Int'
> in block <unit> at -e:1
>
> Presumably it should be forbidden in the "of" form just as it is forbidden
> in the prefix form.
>
> -zefram




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