Skip Menu |
Report information
Id: 79288
Status: resolved
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

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



Subject: [BUG] Can't assign to 'is rw' optional parameters (or parameters with a default) if no argument was provided in Rakudo
Date: Tue, 16 Nov 2010 23:45:18 +0100
To: rakudobug [...] perl.org
From: Carl Mäsak <cmasak [...] gmail.com>
Download (untitled) / with headers
text/plain 736b
<masak> blog post! http://strangelyconsistent.org/blog/november-16-2010-the-polite-revolt <masak> rakudo: sub foo($x? is rw) { $x = "OH HAI" }; foo() <p6eval> rakudo 015d77: OUTPUT«Cannot modify readonly value [...] <masak> discuss. * masak submits rakudobug * masak looks <Tene> masak: A third of the way through or so, I was thinking "Could he use 'is copy' instead?" :) <Tene> masak: I agree in that I expect rw defaults to be a copy/assign. <Tene> masak: Shouldn't be too hard to fix, I expect. <masak> Tene: oh, good. <Tene> I mean, the functionality is obviously already there, as 'is copy' can do it fine, so you'd just look at what's different in the PAST, etc. <jnthn> akshually probably an easy-ish binder patch. <masak> \o/
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.1k
On Tue Nov 16 14:45:34 2010, masak wrote: Show quoted text
> <masak> blog post! > http://strangelyconsistent.org/blog/november-16-2010-the-polite-revolt > <masak> rakudo: sub foo($x? is rw) { $x = "OH HAI" }; foo() > <p6eval> rakudo 015d77: OUTPUT«Cannot modify readonly value [...] > <masak> discuss. > * masak submits rakudobug > * masak looks > <Tene> masak: A third of the way through or so, I was thinking "Could > he use 'is copy' instead?" :) > <Tene> masak: I agree in that I expect rw defaults to be a copy/assign. > <Tene> masak: Shouldn't be too hard to fix, I expect. > <masak> Tene: oh, good. > <Tene> I mean, the functionality is obviously already there, as 'is > copy' can do it fine, so you'd just look at what's different in the > PAST, etc. > <jnthn> akshually probably an easy-ish binder patch. > <masak> \o/
New spec change says this: https://github.com/perl6/specs/commit/44511d749bbbae4286dd1675ad6264c72acd2433 ] Since this option forces an argument to be required, ] it cannot co-exist with any marks that indicate an optional parameter, ] such as C<?> or a default value. Repurposing this ticket to be about that. $ perl6 -e 'sub foo($x? is rw) {}; foo(); say "alive"' alive Should die at compile time.
Download (untitled) / with headers
text/plain 533b
Show quoted text
> New spec change says this: > >
https://github.com/perl6/specs/commit/44511d749bbbae4286dd1675ad6264c72acd2433 Show quoted text
> ] Since this option forces an argument to be required, > ] it cannot co-exist with any marks that indicate an optional > parameter, > ] such as C<?> or a default value. > > Repurposing this ticket to be about that. > > $ perl6 -e 'sub foo($x? is rw) {}; foo(); say "alive"' > alive > > Should die at compile time.
Now it does: ===SORRY!=== Cannot use 'is rw' on an optional parameter Tagging testneeded. /jnthn
RT-Send-CC: perl6-compiler [...] perl.org
On Fri Jan 13 04:54:34 2012, jnthn@jnthn.net wrote: Show quoted text
> > New spec change says this: > > > >
> https://github.com/perl6/specs/commit/44511d749bbbae4286dd1675ad6264c72acd2433
> > ] Since this option forces an argument to be required, > > ] it cannot co-exist with any marks that indicate an optional > > parameter, > > ] such as C<?> or a default value. > > > > Repurposing this ticket to be about that. > > > > $ perl6 -e 'sub foo($x? is rw) {}; foo(); say "alive"' > > alive > > > > Should die at compile time.
> > Now it does: > > ===SORRY!=== > Cannot use 'is rw' on an optional parameter > > Tagging testneeded. > > /jnthn
Still dies at compile time (as expected): $ perl6 -e 'sub foo($x? is rw) {}' ===SORRY!=== Error while compiling -e Cannot use 'is rw' on an optional parameter at -e:1 ------> $ perl6 -e 'sub foo($x is rw = 4) {}' ===SORRY!=== Error while compiling -e Cannot use 'is rw' on an optional parameter at -e:1 ------> I added two tests to S06-signature/optional.t with commit https://github.com/perl6/roast/commit/1014935495 I'm closing this ticket now.


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