On Monday, 25 June 2012 at 14:23:25 UTC, Roman D. Boiko wrote:
import std.range;
struct Element {
  //immutable // uncomment to break compilation
   int _i;
  this(int i) { _i = i; }
}
void main() {
  auto arr = [Element.init];
  arr.front;
}

Declaring _i immutable yields the following compilation error:

/usr/include/x86_64-linux-gnu/dmd/phobos/std/array.d(460): Error: a[0LU] isn't mutable sample.d(11): Error: template instance std.array.front!(Element) error instantiating

Is this a bug, or I misunderstand something?

This is a bug of the compiler, and it is already filed.
http://d.puremagic.com/issues/show_bug.cgi?id=6336

I've already posted a pull request to fix the bug, but it has been hold a while.

Kenji Hara

Reply via email to