[Issue 13610] bringToFront does not work with CTFE

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Oct 14 03:50:06 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13610

--- Comment #1 from Don <clugdbug at yahoo.com.au> ---
(In reply to jens.k.mueller from comment #0)
> bringToFront does not work with CTFE. I don't know whether it is supposed to
> but
> it certainly is surprising.
> 
> import std.algorithm : bringToFront;
> // at running time
> {
> 	auto array = [1, 2, 3, 4];
> 	bringToFront(array[0 .. $-1], array[$-1 .. $]);
> 	assert(array == [4, 1, 2, 3]);
> }
> // at compile time
> {
> 	enum array = [1, 2, 3, 4];
> 	bringToFront(array[0 .. $-1], array[$-1 .. $]);
> 	static assert(array == [4, 1, 2, 3]); // fails

Of course it fails. array is an enum, it can never change. That's the point of
enum!

The confusing thing is that bringToFront compiles when passed a manifest
constant.

--


More information about the Digitalmars-d-bugs mailing list