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

Owner: Nobody
Requestors: lloyd.fourn [at] gmail.com
Cc:
AdminCc:

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



From: Lloyd Fournier <lloyd.fourn [...] gmail.com>
Subject: [BUG] Definitely typed variables have wrong default
To: "rakudobug [...] perl.org" <rakudobug [...] perl.org>
Date: Sat, 28 May 2016 11:58:15 +0000
Download (untitled) / with headers
text/plain 227b
my Str:D $a = Nil; say $a; (Str:D)
say $a.VAR.default; #(Str:D)

:D variables in general cannot have a default default. Therefore if the default default should be to throw an exception when it is acessed. My answer would be:

To: perl6-compiler [...] perl.org, bugs-bitbucket [...] rt.perl.org
Subject: Re: [perl #128277] [BUG] Definitely typed variables have wrong default
From: Lloyd Fournier <lloyd.fourn [...] gmail.com>
Date: Sat, 28 May 2016 12:00:46 +0000
Download (untitled) / with headers
text/plain 731b
(continued :P)
Type check failed in assignment to $a; expected Str:D but got Mu (Mu)
  in block <unit> at -e line 1

It can also happen on assignment to array and hash elements.

On Sat, May 28, 2016 at 9:59 PM Lloyd Fournier <perl6-bugs-followup@perl.org> wrote:
Show quoted text
# New Ticket Created by  Lloyd Fournier
# Please include the string:  [perl #128277]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=128277 >


my Str:D $a = Nil; say $a; # (Str:D)
say $a.VAR.default; #(Str:D)

:D variables in general cannot have a default default. Therefore if the
default default should be to throw an exception when it is acessed. My
answer would be:
To: perl6-compiler [...] perl.org, bugs-bitbucket [...] rt.perl.org
From: Lloyd Fournier <lloyd.fourn [...] gmail.com>
Subject: Re: [perl #128277] [BUG] Definitely typed variables have wrong default
Date: Sat, 28 May 2016 12:02:13 +0000
Download (untitled) / with headers
text/plain 944b
Should be:

Type check failed in assignment to $a; expected Str:D but got (Mu)

(sorry for the spam)

On Sat, May 28, 2016 at 10:00 PM Lloyd Fournier <lloyd.fourn@gmail.com> wrote:
Show quoted text
(continued :P)
Type check failed in assignment to $a; expected Str:D but got Mu (Mu)
  in block <unit> at -e line 1

It can also happen on assignment to array and hash elements.

On Sat, May 28, 2016 at 9:59 PM Lloyd Fournier <perl6-bugs-followup@perl.org> wrote:
# New Ticket Created by  Lloyd Fournier
# Please include the string:  [perl #128277]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=128277 >


my Str:D $a = Nil; say $a; # (Str:D)
say $a.VAR.default; #(Str:D)

:D variables in general cannot have a default default. Therefore if the
default default should be to throw an exception when it is acessed. My
answer would be:
Subject: Re: [perl #128277] [BUG] Definitely typed variables have wrong default
From: Lloyd Fournier <lloyd.fourn [...] gmail.com>
To: perl6-compiler [...] perl.org, bugs-bitbucket [...] rt.perl.org
Date: Sat, 28 May 2016 12:03:16 +0000
Download (untitled) / with headers
text/plain 1.1k
^^ but that was wrong too.

Type check failed in assignment to $a; expected Str:D but got Nil

Going to go lie down for a bit now....


On Sat, May 28, 2016 at 10:02 PM Lloyd Fournier <lloyd.fourn@gmail.com> wrote:
Show quoted text
Should be:

Type check failed in assignment to $a; expected Str:D but got (Mu)

(sorry for the spam)

On Sat, May 28, 2016 at 10:00 PM Lloyd Fournier <lloyd.fourn@gmail.com> wrote:
(continued :P)
Type check failed in assignment to $a; expected Str:D but got Mu (Mu)
  in block <unit> at -e line 1

It can also happen on assignment to array and hash elements.

On Sat, May 28, 2016 at 9:59 PM Lloyd Fournier <perl6-bugs-followup@perl.org> wrote:
# New Ticket Created by  Lloyd Fournier
# Please include the string:  [perl #128277]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=128277 >


my Str:D $a = Nil; say $a; # (Str:D)
say $a.VAR.default; #(Str:D)

:D variables in general cannot have a default default. Therefore if the
default default should be to throw an exception when it is acessed. My
answer would be:
Download (untitled) / with headers
text/plain 593b
To add to the discussion, as it seems related. The errors generated in this case are LTA: <Zoffix> m: sub foo ( Str:D :$a ) {}; foo <camelia> rakudo-moar ac0dcd: OUTPUT«Parameter '$a' requires an instance of type Str, but a type object was passed. Did you forget a .new?␤ in sub foo at <tmp> line 1␤ in block <Zoffix> m: class { method foo (Str:D :$a) {} }.new.foo <camelia> rakudo-moar ac0dcd: OUTPUT«Parameter '$a' requires an instance of type Str, but a type object was passed. Did you forget a .new?␤ in method foo at <tmp> line 1␤ in block <unit> at <tmp> line 1␤␤»


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