https://issues.dlang.org/show_bug.cgi?id=13808

[email protected] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #2 from [email protected] ---
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.

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
    }
}
-----

Note that making the import in S static doesn't help, because static imports
cannot bind specific symbols, so you have to alias specific import symbols...
but that again leaks them to the outside via UFCS.

This is no longer just about std.datetime, this is a glaring hole in the import
system.

--

Reply via email to