develooper Front page | perl.perl6.compiler | Postings from February 2018

[perl #126703] Typed Shaped Arrays can't be initialized

From:
Jan-Olof Hendig via RT
Date:
February 6, 2018 22:27
Subject:
[perl #126703] Typed Shaped Arrays can't be initialized
Message ID:
rt-4.0.24-19667-1517956037-1625.126703-80-0@perl.org
On Sat, 21 Nov 2015 06:48:27 -0800, timo wrote:
> Reproducing test:
> 
> my @a[3;3] = <a b c>, <d e f>, <g h i>; say @a; # works
> my Str @a[3;3] = <a b c>, <d e f>, <g h i>; say @a; # fails
> 
> 153852     jnthn │ m: say ((0 xx 10) xx 10).WHAT
> 153852  +camelia │ rakudo-moar : OUTPUT«(List)␤»
> 153857     jnthn │ Curious...
> 153933  timotimo │ how do you initialize the lists in your multidim 
> tests? :)
> 153935     jnthn │ Curious...I'd kinda have expected that to be a Seq...
> 153955     jnthn │ m: my @a[3;3] = <a b c>, <d e f>, <g h i>; say @a
> 153956  +camelia │ rakudo-moar : OUTPUT«[[a b c] [d e f] [g h i]]␤»
> 154002  timotimo │ mhh
> 154003     jnthn │ m: my @a[3;3] = <a b c> xx 3; say @a
> 154004  +camelia │ rakudo-moar : OUTPUT«[[a b c] [a b c] [a b c]]␤»
> 154014  timotimo │ m: my Str @a[3;3] = <a b c>, <d e f>, <g h i>; say @a
> 154014  +camelia │ rakudo-moar : OUTPUT«Type check failed in assignment 
> to ; expected Str but got List␤  in block
>                   │ <unit> at /tmp/XObUYCKoZZ:1␤␤»
> 154023     jnthn │ m: my @a[3;3] = ('a' xx 3) xx 3; say @a
> 154023  +camelia │ rakudo-moar : OUTPUT«[[a a a] [a a a] [a a a]]␤»
> 154032     jnthn │ Oh...
> 154037  timotimo │ it's really the type annotation; the type check seems 
> to happen in a/the wrong place
> 154047     jnthn │ Yes, looks like it.
> 

Fixed with commit 131367c7daa89d. Test needed.




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About