https://issues.dlang.org/show_bug.cgi?id=13808
--- Comment #4 from Kenji Hara <[email protected]> --- (In reply to hsteoh from comment #2) > Argh... yet another scoped import pathological behaviour. Apparently putting > an import in the body of a struct S pulls symbols into the struct's > namespace, so that S.symbol now refers to the imported symbol. Any imported symbols in struct body scope should not be visible via the struct instance object. > This is really nasty, and greatly limits the usefulness of scoped imports, > for example: > > ----- > // mod.d > module mod; > struct S { > // This is necessary for myFunc, and we can't move it inside myFunc, > // because we need it in the sig constraint > import std.range.primitives : isInputRange; > > auto myFunc(R)(R input) > if (isInputRange!R) > { ... } > } > > // main.d > import mod; > void main() { > S s; > static if (s.isInputRange!(int[])) { // this actually works :-( > ... > } > static if (isInputRange!(int[])) { // whereas this doesn't compile > } > } > ----- My import mechanism improvement will disallow the weird name lookup `s.isInputRange!(int[])`. https://github.com/D-Programming-Language/dmd/pull/3407 --
