On Friday, 1 August 2014 at 07:51:32 UTC, Andrew Godfrey wrote:
Going through other .dd files, I found an error in
expression.dd.
It says "For static or dynamic arrays, identity is defined as
referring
to the same array elements and the same number of elements."
Well, in fact:
unittest {
// expression.dd says that equality AND IDENTITY compare
elements and sizes, for both "static and dynamic arrays". Gaah!
int[] a = new int[3];
int[] b = new int[3];
assert(a == b);
assert(a !is b); // Nope! The doc is wrong!
// So then:
b = a;
assert(b is a); // Now b points to a, and 'is' does what
I'd expect.
// But evidently it's because it compared the array
references - not
// the elements and sizes!
}
I would NOT recommend updating the compiler to match what the
doc says.
The current behavior is consistent with how assignment to an
array reference behaves.
Rereading this, the original text did say "refers to". So calling
that an "error" may be a bit strong.