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

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

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



Subject: [BUG] Multiple dispatch doesn't treat 'rw' parameters as narrower than readonly parameters in Rakudo
Date: Fri, 16 Apr 2010 10:30:49 +0200
To: rakudobug [...] perl.org
From: Carl Mäsak <cmasak [...] gmail.com>
Download (untitled) / with headers
text/plain 816b
<masak> rakudo: multi foo(Int $x is rw) { say "writable" }; multi foo(Int $x) { "readonly" }; foo(42) <p6eval> rakudo 78faa0: OUTPUT«Ambiguous dispatch to multi 'foo'. Ambiguous candidates had signatures:␤:(Int $x)␤:(Int $x) [...] * masak submits rakudobug <masak> S06: "To allow modification, use the C<is rw> trait. This requires a mutable object or container as an argument (or some kind of type object that can be converted to a mutable object, such as might be returned by an array or hash that knows how to autovivify new elements). Otherwise the signature fails to bind, and this candidate routine cannot be considered for servicing this particular call. (Other multi candidates, if any, may succeed if they don't require C<rw> for this parameter.)" <moritz_> now you're just showing off :-) <masak> :P
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.3k
On Fri Apr 16 01:31:22 2010, masak wrote: Show quoted text
> <masak> rakudo: multi foo(Int $x is rw) { say "writable" }; multi > foo(Int $x) { "readonly" }; foo(42) > <p6eval> rakudo 78faa0: OUTPUT«Ambiguous dispatch to multi 'foo'. > Ambiguous candidates had signatures:␤:(Int $x)␤:(Int $x) [...] > * masak submits rakudobug > <masak> S06: "To allow modification, use the C<is rw> trait. This > requires a mutable object or container as an argument (or some kind of > type object that can be converted to a mutable object, such as might > be returned by an array or hash that knows how to autovivify new > elements). Otherwise the signature fails to bind, and this candidate > routine cannot be considered for servicing this particular call. > (Other multi candidates, if any, may succeed if they don't require > C<rw> for this parameter.)" > <moritz_> now you're just showing off :-) > <masak> :P
Behavior is mostly unchanged since 2010 - error message has better signature reporting, but still reported as ambiguous. 20:36 <[Coke]> m: multi foo(Int $x is rw) { say "writable" }; multi foo(Int $x) { "readonly" }; foo(42) 20:36 <camelia> rakudo-moar b2b333: OUTPUT«Ambiguous call to 'foo'; these signatures all match:␤:(Int $x is rw)␤:(Int $x)␤ in sub foo at /tmp/CwM3ZkL1nu:1␤ in block at /tmp/CwM3ZkL1nu:1␤␤» -- Will "Coke" Coleda
Download (untitled) / with headers
text/plain 1.7k
On Sat Feb 22 17:37:47 2014, coke wrote: Show quoted text
> On Fri Apr 16 01:31:22 2010, masak wrote:
> > <masak> rakudo: multi foo(Int $x is rw) { say "writable" }; multi > > foo(Int $x) { "readonly" }; foo(42) > > <p6eval> rakudo 78faa0: OUTPUT«Ambiguous dispatch to multi 'foo'. > > Ambiguous candidates had signatures:␤:(Int $x)␤:(Int $x) [...] > > * masak submits rakudobug > > <masak> S06: "To allow modification, use the C<is rw> trait. This > > requires a mutable object or container as an argument (or some kind > > of > > type object that can be converted to a mutable object, such as might > > be returned by an array or hash that knows how to autovivify new > > elements). Otherwise the signature fails to bind, and this candidate > > routine cannot be considered for servicing this particular call. > > (Other multi candidates, if any, may succeed if they don't require > > C<rw> for this parameter.)" > > <moritz_> now you're just showing off :-) > > <masak> :P
> > Behavior is mostly unchanged since 2010 - error message has better > signature reporting, but still reported as ambiguous. > > 20:36 <[Coke]> m: multi foo(Int $x is rw) { say "writable" }; multi > foo(Int $x) > { "readonly" }; foo(42) > 20:36 <camelia> rakudo-moar b2b333: OUTPUT«Ambiguous call to 'foo'; > these > signatures all match:␤:(Int $x is rw)␤:(Int $x)␤ in > sub foo at > /tmp/CwM3ZkL1nu:1␤ in block at /tmp/CwM3ZkL1nu:1␤␤»
With Rakudo commits 8cba8863 and ed10656c this now behaves as follow: 15:52 < psch> m: multi foo(Int $x is rw) { say "writable" }; multi foo(Int $x) { "readonly" }; say foo(42); foo my $ = 42; 15:52 <+camelia> rakudo-moar ed1065: OUTPUT«readonly␤writable␤» I've also added S06-multi/by-trait.t to spectest.data which tests this.
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 2.3k
On Tue Nov 10 07:55:06 2015, peschwa@gmail.com wrote: Show quoted text
> On Sat Feb 22 17:37:47 2014, coke wrote:
> > On Fri Apr 16 01:31:22 2010, masak wrote:
> > > <masak> rakudo: multi foo(Int $x is rw) { say "writable" }; multi > > > foo(Int $x) { "readonly" }; foo(42) > > > <p6eval> rakudo 78faa0: OUTPUT«Ambiguous dispatch to multi 'foo'. > > > Ambiguous candidates had signatures:␤:(Int $x)␤:(Int $x) [...] > > > * masak submits rakudobug > > > <masak> S06: "To allow modification, use the C<is rw> trait. This > > > requires a mutable object or container as an argument (or some kind > > > of > > > type object that can be converted to a mutable object, such as > > > might > > > be returned by an array or hash that knows how to autovivify new > > > elements). Otherwise the signature fails to bind, and this > > > candidate > > > routine cannot be considered for servicing this particular call. > > > (Other multi candidates, if any, may succeed if they don't require > > > C<rw> for this parameter.)" > > > <moritz_> now you're just showing off :-) > > > <masak> :P
> > > > Behavior is mostly unchanged since 2010 - error message has better > > signature reporting, but still reported as ambiguous. > > > > 20:36 <[Coke]> m: multi foo(Int $x is rw) { say "writable" }; multi > > foo(Int $x) > > { "readonly" }; foo(42) > > 20:36 <camelia> rakudo-moar b2b333: OUTPUT«Ambiguous call to 'foo'; > > these > > signatures all match:␤:(Int $x is rw)␤:(Int $x)␤ in > > sub foo at > > /tmp/CwM3ZkL1nu:1␤ in block at /tmp/CwM3ZkL1nu:1␤␤»
> > With Rakudo commits 8cba8863 and ed10656c this now behaves as follow: > > 15:52 < psch> m: multi foo(Int $x is rw) { say "writable" }; multi > foo(Int $x) { "readonly" }; say foo(42); foo my $ = 42; > 15:52 <+camelia> rakudo-moar ed1065: OUTPUT«readonly␤writable␤» > > I've also added S06-multi/by-trait.t to spectest.data which tests > this.
psch++ also updated most of the multi-dispatch caching logic to get things performing well again. Today I updated the dynamic optimizer in Moar to understand the new multi-dispatch flag, so we don't go mis-inlining. And fixed a further static optimizer issue where it wasn't aware of `is rw` and so could mis-dispatch. Both covered by more tests in S06-multi/by-trait.t. So, we can consider this done. /jnthn


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