Skip Menu |
Report information
Id: 126891
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)



Subject: [BUG] module objects badly behaved for type checks
From: Zefram <zefram [...] fysh.org>
Date: Sun, 13 Dec 2015 05:56:37 +0000
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 766b
Show quoted text
> my Int $a = CORE > $a.WHAT.say
(CORE) Show quoted text
> CORE.^isa(Int)
Cannot call isa(Perl6::Metamodel::ModuleHOW: CORE, Int); none of these signatures match: (Mu \SELF: Mu $type, *%_) (Mu \SELF: Str:D $name, *%_) in block <unit> at <unknown file>:1 Show quoted text
> (sub (Int $a) { 1 })(CORE)
Type check failed in binding $a; expected Int but got CORE in sub at <unknown file>:1 in block <unit> at <unknown file>:1 CORE is a module object; other module objects behave similarly. As shown above, they can be assigned to type-constrained variables despite not meeting the type constraint. Additionally, the .^isa method fails to operate on them; don't know whether these two faults are really related. Type constraint does apply as expected to a subroutine parameter. -zefram
Date: Sun, 13 Dec 2015 10:06:38 +0000
Subject: Re: [perl #126891] [BUG] module objects badly behaved for type checks
To: "Zefram (via RT)" <perl6-bugs-followup [...] perl.org>
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
Download (untitled) / with headers
text/plain 1.4k
Zefram, Show quoted text
> On 13 Dec 2015, at 05:56, Zefram (via RT) <perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by Zefram > # Please include the string: [perl #126891] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=126891 > > >
>> my Int $a = CORE >> $a.WHAT.say
> (CORE)
>> CORE.^isa(Int)
> Cannot call isa(Perl6::Metamodel::ModuleHOW: CORE, Int); none of these signatures match: > (Mu \SELF: Mu $type, *%_) > (Mu \SELF: Str:D $name, *%_) > in block <unit> at <unknown file>:1
>> (sub (Int $a) { 1 })(CORE)
> Type check failed in binding $a; expected Int but got CORE > in sub at <unknown file>:1 > in block <unit> at <unknown file>:1 > > CORE is a module object; other module objects behave similarly. As shown > above, they can be assigned to type-constrained variables despite not > meeting the type constraint. Additionally, the .^isa method fails to > operate on them; don't know whether these two faults are really related. > Type constraint does apply as expected to a subroutine parameter.
thanks for submitting these tickets! Some further data points: This seems to apply to any variable type and any PseudoStash: $ 6 'my Str $a = MY; say $a' (MY) Oddly enough, binding *does* fail with a typecheck error: $ 6 'my Str $a := GLOBAL' Type check failed in binding; expected Str but got GLOBAL in block <unit> at -e:1 Liz
To: Elizabeth Mattijsen via RT <perl6-bugs-followup [...] perl.org>
From: Zefram <zefram [...] fysh.org>
Subject: Re: [perl #126891] [BUG] module objects badly behaved for type checks
Date: Wed, 16 Dec 2015 00:28:26 +0000
Download (untitled) / with headers
text/plain 332b
Elizabeth Mattijsen via RT wrote: Show quoted text
>This seems to apply to any variable type and any PseudoStash:
Further generalisation: it also happens for any package object (GLOBAL, MAIN) and any role object (Iterable, Dateish). In both cases, the .^isa misbehaviour is seen as well as the actual ability to bypass type constraints. -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