Bug 19103 – Can imports symbols in module to a struct with mixin.
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2018-07-20T00:11:00Z
Last change time
2018-12-24T19:22:43Z
Assigned to
No Owner
Creator
kntroh
Comments
Comment #0 by kntroh — 2018-07-20T00:11:00Z
Mixing import statements in a struct.
Then symbols in the module will be imported as a members of the struct.
This bug seems to be from dmd 2.080.0 to current nightly build.
---
void main() {
//(new C).writeln("OK."); // Error: no property writeln for type test.C, did you mean std.stdio.writeln(T...)(T args)?
S1 s1;
s1.writeln("Hey?"); // It can be compiled and runs!
S2 s2;
//s2.writeln("OK."); // Error: no property writeln for type S2, did you mean std.stdio.writeln(T...)(T args)?
}
mixin template T() {
import std.stdio;
}
class C {
mixin T;
}
struct S1 {
mixin T;
}
struct S2 {
private import std.stdio;
}
Comment #1 by greeenify — 2018-07-20T00:55:59Z
> This bug seems to be from dmd 2.080.0 to current nightly build.
I'm not sure it's a regression, because that's what DMD is doing since 2.071:
https://run.dlang.io/is/nhCVXe
Before 2.071, there was only one global import namespace, which is why this probably worked before.
The interesting thing is that only since 2.079.1, `s1.writeln` works.
Digger points at https://github.com/dlang/dmd/pull/7668 which got this working.