[Issue 21464] New: Superfluous module-level import affects attribute inference

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 9 13:41:05 UTC 2020


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

          Issue ID: 21464
           Summary: Superfluous module-level import affects attribute
                    inference
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: kinke at gmx.net

Compiling the following with `-version=Bug` shows that the superfluous import
leads to `pure` being wrongly inferred for the Vector destructor:

```
module bug;

version (Bug)
{
    import std.experimental.allocator.mallocator : Mallocator;
}

struct Vector(Allocator)
{
    ~this()
    {
        import std.experimental.allocator : dispose;
        char[] elements = null;
        Allocator.instance.dispose(elements);
    }
}

void main()
{
    import std.experimental.allocator.mallocator : Mallocator;
    Vector!Mallocator ret;
    static assert(ret.__dtor.mangleof ==
"_D3bug__T6VectorTS3std12experimental9allocator10mallocator10MallocatorZQCk6__dtorMFNbNiZv");
}
```

The non-Bug version works with DMD 2.077+, the Bug version fails since DMD
2.080.

[The real-world symptom was an undefined-symbol linker error...]

--


More information about the Digitalmars-d-bugs mailing list