Thread overview
[Issue 24216] All symbols from object are publicly imported into every module
Nov 01, 2023
Adam D. Ruppe
Nov 01, 2023
Adam D. Ruppe
November 01, 2023
https://issues.dlang.org/show_bug.cgi?id=24216

Adam D. Ruppe <destructionator@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator@gmail.com

--- Comment #1 from Adam D. Ruppe <destructionator@gmail.com> ---
Not specific to object, this happens with all modules, but also not all symbols, it only applies to types. Does not happen with variables or functions.

--
November 01, 2023
https://issues.dlang.org/show_bug.cgi?id=24216

--- Comment #2 from Steven Schveighoffer <schveiguy@gmail.com> ---
Please post examples to confirm.

I tried this, and it compiles, so it's not just types:

```d
import std.math;

void main()
{
    int[int] x;
    std.math.require(x, 5) = 6;
}
```

--
November 01, 2023
https://issues.dlang.org/show_bug.cgi?id=24216

--- Comment #3 from Adam D. Ruppe <destructionator@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?

--
November 02, 2023
https://issues.dlang.org/show_bug.cgi?id=24216

--- Comment #4 from Steven Schveighoffer <schveiguy@gmail.com> ---
FWIW, this was found in discord by someone asking what `std.stdio.string` is. So it's not just std.math.

I just picked std.math as something I thought would likely not be dealing with `string`.

But I also tried local modules without anything in it, and `mod1.string` worked.

--