[Issue 24216] All symbols from object are publicly imported into every module

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 1 23:59:51 UTC 2023


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

--- Comment #3 from Adam D. Ruppe <destructionator at gmail.com> ---
OK, this gets weirder and weirder.

Make three modules:

mod.d
```
import mod2;
import std.math;

void main() {
        string[int] x;
        // mod2.Object lol = mod2.require(x, 5);
        mod2.bar test = mod2.lol;
}
```

mod2.d
```
import mod3;

void foo() {}
```

mod3.d
```
struct bar {}

bar lol;
```

Error: undefined identifier `lol` in module `mod2`, did you mean variable
`lol`?

It allowed mod2.bar, the type, but not mod2.lol, the variable. This shows
something is off without being just `object`.

Swap the commented lines and again it allows mod2.Object but not mod2.require.
Appears to be the same behavior with `object`.


Now change the name to twoname.mod2 instead of mod2. No difference.

But now use std.math instead and instead of "undefinied identifier require" you
get "cannot implicitly convert expression require".

So why is it different with a user-defined module than with std.math?

--


More information about the Digitalmars-d-bugs mailing list