Skip Menu |

This queue is for tickets about the Kavorka CPAN distribution.

Report information
The Basics
Id: 97782
Status: open
Priority: 0/
Queue: Kavorka

People
Owner: Nobody in particular
Requestors: ilmari.ikonen [...] outlook.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Kavorka signature bug
Date: Wed, 6 Aug 2014 17:51:56 +0300
To: "bug-Kavorka [...] rt.cpan.org" <bug-kavorka [...] rt.cpan.org>
From: ilmari ikonen <ilmari.ikonen [...] outlook.com>
The following code fails on Kavorka-0.030 (the latest at this time): use v5.14;use Kavorka; fun test(Num $a, :$b = 1 --> Num ){} The error message is Can't modify constant item in postdecrement (--) at test.pl line 4, near "1 --" It works without the return type. I am using perl 5.20 on Linux debian 3.2.0-4-686-pae #1 SMP Debian 3.2.60-1+deb7u1 i686 GNU/Linux
The "--" part is taken to be a post-decrement operator on the "1". When you supply a default value for a parameter, you can use operators in that default; e.g. fun blah ($a=1, $b=2+2) { ... } The expression is parsed as an "arithexpr". If you look at the list of operators under "Operator Precedence and Associativity" in perlop, that's everything up to and including the bitshift operators "<<" and ">>". An arithexpr needs to be terminated by something like a comma or a closing bracketing character. So a workaround could be something like: fun test(Num $a, :$b = 1, ... --> Num ){} This means you sacrifice argument count checking though. :-(