On Thursday, 6 June 2019 at 17:40:17 UTC, Machine Code wrote:
outside an unittest, this compiles fine:
struct A
{
enum A foo = "hehe";
this(string a) { m_a = a; }
alias m_a this;
string m_a;
}
but if you wrap this a unittest {} and compile with
dmd -unittest -run foo.d
this give the following error:
cannot implicitly convert expression "hehe" of type string to A
Why does inside a unittest it doesn't work? the constructor
this(string) {} seems to get disabled.
I this notice albeit a simple cast workaround that:
enum A foo = cast(A)"hehe";
or better:
enum foo = A("hehe");
but isn't that a bug? what am I missing?