Created attachment 1166
code sample that gets mixed in
The test case are 2 files one is main and the other is being mixed in via
import("tables.d").
command line:
dmd -J. -c mixin_order.d
dmd is 2.061 from github master.
struct RleBitSet(T)
{
this(const(T)[] arr)const{ }
}
auto asSet(T)(in SetEntry!T e)
{
return RleBitSet!T(e.data);
}
//this way works
//mixin(import("tables.d"));
immutable NFCN = asSet(NFC_QCN);
immutable NFCM = asSet(NFC_QCM);
//this doesn't
mixin(import("tables.d"));
//-------------------
// tables.d (also attached)
//-------------------
struct SetEntry(T)
{
T[] data;
}
immutable NFC_QCN = SetEntry!uint([1,2,3,4]);
immutable NFC_QCM = SetEntry!uint([1,2,3,4]);
It is expected that mixin(import("...")) makes code appear to be effectively
pasted just there but obviously some processing step is missing as it doesn't
work this way.
Comment #1 by dmitry.olsh — 2012-12-08T14:29:38Z
Created attachment 1167
the test case itself
Comment #2 by dmitry.olsh — 2013-10-20T06:15:20Z
Still fails with 2.064.
Comment #3 by dkorpel — 2018-12-04T14:04:49Z
Can be reduced to:
```
immutable int a = b;
mixin("immutable int b = 3;");
```
Output as of 2.083:
Error: undefined identifier b
It compiles when swapping the two lines or when removing the mixin and directly putting the declaration in the code.
Comment #4 by robert.schadek — 2024-12-13T18:03:13Z