Bug 21464 – Superfluous module-level import affects attribute inference

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-12-09T13:41:05Z
Last change time
2020-12-20T14:08:11Z
Keywords
pull
Assigned to
No Owner
Creator
kinke

Comments

Comment #0 by kinke — 2020-12-09T13:41:05Z
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...]
Comment #1 by dlang-bot — 2020-12-10T13:31:44Z
@kinke created dlang/dmd pull request #12023 "[stable] Fix Issue 21464 - Purity check depending on semantic order" fixing this issue: - Fix Issue 21464 - Purity check depending on semantic order Accessing a mutable static but empty struct is pure. The check relied on `StructDeclaration.hasNoFields` but didn't make sure the struct size has already been determined. https://github.com/dlang/dmd/pull/12023
Comment #2 by dlang-bot — 2020-12-10T14:42:01Z
dlang/dmd pull request #12023 "[stable] Fix Issue 21464 - Purity check depending on semantic order" was merged into stable: - 3c12cbcbe376652395266a0ae458302ff0b9def2 by Martin Kinkelin: Fix Issue 21464 - Purity check depending on semantic order Accessing a mutable static but empty struct is pure. The check relied on `StructDeclaration.hasNoFields` but didn't make sure the struct size has already been determined. https://github.com/dlang/dmd/pull/12023
Comment #3 by dlang-bot — 2020-12-20T14:08:11Z
dlang/dmd pull request #12040 "merge stable" was merged into master: - d3091c204e698798ab58d443dd848e3db5759aa1 by Martin Kinkelin: Fix Issue 21464 - Purity check depending on semantic order Accessing a mutable static but empty struct is pure. The check relied on `StructDeclaration.hasNoFields` but didn't make sure the struct size has already been determined. https://github.com/dlang/dmd/pull/12040