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.
Comment #2 by rburners — 2018-07-20T08:48:00Z
Comment #3 by razvan.nitu1305 — 2018-12-14T13:33:33Z
Comment #4 by github-bugzilla — 2018-12-24T19:22:37Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/c36b5908264dc1a24ef5b369e1abb702e29b611b Fix Issue 19103 - Can imports symbols in module to a struct with mixin https://github.com/dlang/dmd/commit/5cb179f804695bf5a9513916b3552a24f77c5eab Merge pull request #9078 from RazvanN7/Issue_19103 Fix Issue 19103 - Can imports symbols in module to a struct with mixin