Additional information: one also gets identical .WHICH values for
scalars that are not actually part of the same array but arise from a
single declaration that executes multiple times. This can happen for
a declaration of an array variable or of a scalar variable.
Here's another formulation of the demo, which illustrates the above and
also makes clearer the access of contained value via the container object.
(I wish the Scalar class were natively as easy to use explicitly as the
functions here make it.)
> sub scalar-make(Mu $iv) { my $v = $iv; $v.VAR }
sub scalar-make (Mu $iv) { #`(Sub|92435288) ... }
> sub scalar-get(Scalar:D $s) { my $v := $s; $v }
sub scalar-get (Scalar:D $s) { #`(Sub|92435440) ... }
> sub scalar-set(Scalar:D $s, Mu $nv) { my $v := $s; $v = $nv }
sub scalar-set (Scalar:D $s, Mu $nv) { #`(Sub|92435592) ... }
> my $x = scalar-make(22)
22
> my $y = scalar-make(33)
33
> scalar-get($x)
22
> scalar-get($y)
33
> scalar-set($x, 44)
44
> scalar-get($x)
44
> scalar-get($y)
33
> $x.WHICH
Scalar|128188776
> $y.WHICH
Scalar|128188776
> $x === $y
True
> scalar-get($x).WHICH
Int|44
> scalar-get($y).WHICH
Int|33
> scalar-get($x) === scalar-get($y)
False
-zefram