www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23655] New: __traits(toType) shatters modularity

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

          Issue ID: 23655
           Summary: __traits(toType) shatters modularity
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: destructionator gmail.com

This might not technically be a bug since the spec says "a type that has been
seen by the implementation" but this is is a bad feature regardless.

```
struct S {};

alias t = __traits(toType, "S6totype1S");
```

then make a totype.d with `struct S {}`

compile:

$ dmd totype2.d
totype2.d(3): Error: cannot determine `__traits(toType, "S6totype1S")`


then compile:

$ dmd totype.d totype2.d
fine!


then compile:
$ dmd totype2.d totype.d
totype2.d(3): Error: cannot determine `__traits(toType, "S6totype1S")`


D has very few features that cross modules like this and they're bad to have.
We should start removing these things, especially when they are unused and
unnecessary, to remove potential for more serious order of eval bugs arising
from them.

--
Jan 26 2023