Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array "of" types mutate array class for other arrays #4577

Closed
p6rt opened this issue Sep 21, 2015 · 4 comments
Closed

array "of" types mutate array class for other arrays #4577

p6rt opened this issue Sep 21, 2015 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 21, 2015

Migrated from rt.perl.org#126136 (status was 'resolved')

Searchable as RT126136$

@p6rt
Copy link
Author

p6rt commented Sep 21, 2015

From zefram@fysh.org

$ ./perl6 -e 'my @​a of Int; say @​a.of, " ", @​a.WHAT; my @​b; say @​b.of, " ", @​b.WHAT'
(Int) (Array[Int])
(Mu) (Array[Int])

The first array here is accurately described as Array[Int], matching
the declaration. The second has no element type constraint declared, so
could be accurately described as Array[Mu] or just as Array, but it claims
to be an Array[Int]. It actually behaves as declared, as Array[Mu].

Things get even weirder if the second array has an "of" type too​:

$ ./perl6 -e 'my @​a of Int; say @​a.of, " ", @​a.WHAT; my @​b of Str; say @​b.of, " ", @​b.WHAT'
(Int) (Array[Int][Str])
(Str) (Array[Int][Str])

Now both array declarations have contributed parts to a single array
class seen by both array objects. The expression by which this class
is described causes an error if evaluated.

This bizarre behaviour does not occur if the type constraints are
expressed in prefix form. If one of the arrays uses prefix syntax and
the other "of", or one no explicit element type and the other "of", then
various results are seen, mostly involving some of this bizarre behaviour.

-zefram

@p6rt
Copy link
Author

p6rt commented Sep 10, 2016

From @zoffixznet

Thanks for the report.

This has been fixed sometime pre-Christmas.
Tests added in Raku/roast@feb0022c7d

On Mon Sep 21 15​:25​:42 2015, zefram@​fysh.org wrote​:

$ ./perl6 -e 'my @​a of Int; say @​a.of, " ", @​a.WHAT; my @​b; say @​b.of,
" ", @​b.WHAT'
(Int) (Array[Int])
(Mu) (Array[Int])

The first array here is accurately described as Array[Int], matching
the declaration. The second has no element type constraint declared,
so
could be accurately described as Array[Mu] or just as Array, but it
claims
to be an Array[Int]. It actually behaves as declared, as Array[Mu].

Things get even weirder if the second array has an "of" type too​:

$ ./perl6 -e 'my @​a of Int; say @​a.of, " ", @​a.WHAT; my @​b of Str; say
@​b.of, " ", @​b.WHAT'
(Int) (Array[Int][Str])
(Str) (Array[Int][Str])

Now both array declarations have contributed parts to a single array
class seen by both array objects. The expression by which this class
is described causes an error if evaluated.

This bizarre behaviour does not occur if the type constraints are
expressed in prefix form. If one of the arrays uses prefix syntax and
the other "of", or one no explicit element type and the other "of",
then
various results are seen, mostly involving some of this bizarre
behaviour.

-zefram

@p6rt
Copy link
Author

p6rt commented Sep 10, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 10, 2016

@zoffixznet - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Sep 10, 2016
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant