digitalmars.D.bugs - [Issue 18517] New: Import order is not invariant
- d-bugmail puremagic.com (87/87) Feb 24 2018 https://issues.dlang.org/show_bug.cgi?id=18517
https://issues.dlang.org/show_bug.cgi?id=18517 Issue ID: 18517 Summary: Import order is not invariant Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: johnnymarler gmail.com Currently, compilation will change depending on the order that imports are processed. This order is determined by the order that modules are passed to the compiler on the command line, and also the order they appear in each individual file. Here are some examples: Import order in file changes output: --- foo.d version (A) { static import baz; static import bar; } version (B) { static import bar; static import baz; } void main() { import std.stdio; writeln(bar.thing); writeln(baz.thing); } --- bar.d module baz; enum thing = "this is baz from bar.d"; --- baz.d module bar; enum thing = "this is bar from baz.d"; dmd -version=A -run foo.d ---- this is bar from baz.d this is bar from baz.d ---- dmd -version=B -run foo.d ---- this is baz from bar.d this is baz from bar.d ---- Output changes depending on order of modules passed on the command line: --- main.d import ibar, ibaz; void main() { ibarfunc(); ibazfunc(); } --- ibar.d import bar, std.stdio; void ibarfunc() { writeln(thing); } --- ibaz.d import baz, std.stdio; void ibazfunc() { writeln(thing); } --- bar.d module baz; enum thing = "this is baz from bar.d"; --- baz.d module bar; enum thing = "this is bar from baz.d"; dmd ibar.d ibaz.d -run main.d OUTPUT: this is baz from bar.d this is baz from bar.d dmd ibaz.d ibar.d -run main.d OUTPUT: this is bar from baz.d this is bar from baz.d A PR to fix this has been submitted: https://github.com/dlang/dmd/pull/7900 --
Feb 24 2018