Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #118053] cannot specify optional positional with Mu as default

4 views
Skip to first unread message

Elizabeth Mattijsen

unread,
May 19, 2013, 12:41:10 PM5/19/13
to bugs-bi...@rt.perl.org
# New Ticket Created by Elizabeth Mattijsen
# Please include the string: [perl #118053]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=118053 >


[18:35:53] <lizmat> r: sub a ($a=Mu) { }; a
[18:35:54] <+camelia> rakudo 9c5650: OUTPUT«Nominal type check failed for parameter '$a'; expected Any but got Mu instead␤ in sub a at /tmp/IvMlnzFJOY:1␤ in block at /tmp/IvMlnzFJOY:1␤␤»
[18:36:18] <lizmat> expected Any? but but, I specified Mu as the default

Moritz Lenz

unread,
May 19, 2013, 12:53:03 PM5/19/13
to perl6-c...@perl.org
Any is the default type constraint if you specify none; So you specify a
default that doesn't pass the type constraint, and it dies when you
don't specify a value.

If you want it to be able to receive a Mu, you have to add a type
constraint:

sub a(Mu $a = Mu) { }; a;

or simply

sub a(Mu $a?) { }; a;

So, not a bug.

Cheers,
Moritz
0 new messages