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

[perl #118063] [BUG] comma (wrongly) required between parameter with default value and returns-arrow ('-->') in Rakudo

4 views
Skip to first unread message

Carl Mäsak

unread,
May 20, 2013, 8:52:32 AM5/20/13
to bugs-bi...@rt.perl.org
# New Ticket Created by "Carl Mäsak"
# Please include the string: [perl #118063]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=118063 >


<lizmat> r: sub a ( $a=1, --> Hash ) { say $a; my %h }; say a(2)
<camelia> rakudo 8d2ec9: OUTPUT«2␤().hash␤»
<lizmat> r: sub a ( $a=1 --> Hash ) { say $a; my %h }; say a(2)
<camelia> rakudo 8d2ec9: OUTPUT«===SORRY!===␤Missing block␤at
/tmp/NxD226NWlT:1␤------> sub a ( $a=1 --> Hash ⏏) { say $a; my %h };
say a(2)␤ expecting any of:␤ postfix␤ infix stopper␤
infix or meta-infix␤ prefix or term␤ …
<lizmat> for some reason, if we have a default, we need a comma there
<lizmat> r: sub a ( $a --> Hash ) { say $a; my %h }; say a(2)
<camelia> rakudo 8d2ec9: OUTPUT«2␤().hash␤»
* masak submits rakudobug for the required comma

I have a feeling I know what's up. The default puts the parser in EXPR
mode. The '-->' should be a stopper, but it isn't, so it gets parsed
as '- ->', binary minus and a pointy. The Hash gets gobbled up as a
parameter, and then the parser expects a block, not ')'. This is
consistent with the error message.

Christian Bartolomaeus via RT

unread,
Oct 15, 2014, 5:00:01 PM10/15/14
to perl6-c...@perl.org
This works now without the comma:

$ perl6-m -e 'sub a ( $a=1 --> Hash ) { say $a; my %h }; say a(2)'
2

^^ empty string here ;-)

I added a test to S06-signature/defaults.t with the following commit: https://github.com/perl6/roast/commit/4485db4547
0 new messages