Skip Menu |
Report information
Id: 131397
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: thundergnat [at]

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

From: thundergnat <thundergnat [...]>
To: rakudobug [...]
Date: Mon, 29 May 2017 17:14:29 -0400
Subject: semicolon subscripting in multi dim arrays has odd interactions with numeric string indexes
Download (untitled) / with headers
text/plain 1.9k
Semicolon subscripting in multi dim arrays has odd interactions with indexes that are numeric strings ( but not IntStrings ) See gist: sub d(*@d) { #say @d; # Debugging my @a = [0, 1], [1, 0]; my $r = 0; for @d -> $c { $r = @a[$r;$c] }; print $r.WHAT.gist, ', '; # Debugging $r }; say d( (1,1,0).List ); say d( (1,1,0).Seq ); say d( (1,1,0).Array ); say d( [1,1,0] ); say d( <1 1 0> ); say d( 1,1,0 ); say d( 110.comb ); # WAT See IRClogs around <thundergnat> Hmmm. Don't know if this rises to the level of a bug, it it is certainly a WAT at least to me. <thundergnat> m: <camelia> rakudo-moar 608e88: OUTPUT: «(Int), 0␤(Int), 0␤(Int), 0␤(Int), 0␤(Int), 0␤(Int), 0␤(List), (1)␤» <lizmat> hmmm.. I guess we could have a .comb candidate for Int that would generate Int's <lizmat> but that feels a bit too magic <thundergnat> lizmat: The weird thing is that the d sub gets an array from .comb like every other instance, it just treats the array subindexing differently. <lizmat> because it gets Str as indexes <thundergnat> as does <1 1 0> but _that_ works as expected... <lizmat> thundergnat: but those are IntStr's <lizmat> so they use the Int candidate <thundergnat> erm... Good point. <lizmat> m: dd <1>, "1" <camelia> rakudo-moar 608e88: OUTPUT: «, "1")␤"1"␤» <thundergnat> Anyway, As I said not really a bug, but it confused me for about 15 minutes today. <lizmat> thundergnat: I think this WAT warrants a rakudobug fwiw <lizmat> it shouldn't make a difference <thundergnat> Want me to rakudobug it? <thundergnat> lizmat The other odd thing; if I do the subscripting as @d[$r][$c] ( rather than @d[$r;$c] ) it works as expected in all cases. <lizmat> yeah, so the [;] candidate handles Str differently <lizmat> definitely rakudobug this :-)
Download (untitled) / with headers
text/plain 217b
Shorter example: my @a = [2, 4], [6, 8]; say @a[1; 1].perl; # 8 say @a["1"; "1"].perl; # (8,) PS: Definitely seems related to the following ticket:
Download (untitled) / with headers
text/plain 278b
m: dd (<a b>,)[0;1] rakudo-moar bdf201: OUTPUT: «"b"␤» m: dd (<a b>,)[0;"1"] rakudo-moar bdf201: OUTPUT: «("b",)␤»

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at