Comment #0 by bearophile_hugs — 2012-03-19T17:22:46Z
I don't know if it's possible to fix this just changing Phobos. Maybe more is needed.
Tests performed with DMD 2.059head:
This compiles:
alias int[] Arr;
immutable Arr a;
pure nothrow static this() {
a = [1, 2, 3];
}
void main() {}
This compiles (with -d):
typedef int[] Arr;
immutable Arr a;
pure nothrow static this() {
a = [1, 2, 3];
}
void main() {}
This compiles:
import std.typecons: Typedef;
alias Typedef!(int[]) Arr;
Arr a;
nothrow static this() {
a = [1, 2, 3];
}
void main() {}
But this doesn't compile:
import std.typecons: Typedef;
alias Typedef!(int[]) Arr;
immutable Arr a;
pure nothrow static this() {
a = [1, 2, 3];
}
void main() {}
It gives:
test.d(5): Error: template std.typecons.Typedef!(int[],null).Typedef.Proxy!(Typedef_payload).opAssign(this X,V) does not match any function template declaration
test.d(5): Error: template std.typecons.Typedef!(int[],null).Typedef.Proxy!(Typedef_payload).opAssign(this X,V) cannot deduce template function from argument types !()(int[])
Comment #1 by k.hara.pg — 2013-03-11T18:34:28Z
This is non-const object initialization problem.
Comment #2 by bearophile_hugs — 2013-11-23T14:20:41Z
See also Issue 11584
Comment #3 by bugzilla — 2019-12-22T07:39:50Z
Meanwhile the first two examples do not compile anymore. IMHO because of this, the last one should not compile too.