Error: non-constant expression

Dfr deflexor at yandex.ru
Wed Dec 25 22:33:34 PST 2013


Hello, this example:

import std.array;
import std.algorithm;
import std.typecons;

auto a = [["test", "1"]];
auto b = a.map!(x=>tuple(x[1],x[0])).assocArray;

Gives me
Error: static variable a cannot be read at compile time

When add "const":

const auto a = [["test", "1"]];
const auto b = a.map!(x=>tuple(x[1],x[0])).assocArray;

Gives another error:
Error: non-constant expression ["1":"test"]

Any idea what is wrong ?


More information about the Digitalmars-d-learn mailing list