Bug 16160 – Selective imports in aggregate types shadow methods

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-06-10T20:13:13Z
Last change time
2022-11-09T14:52:21Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Robert Schadek
See also
https://issues.dlang.org/show_bug.cgi?id=10658

Comments

Comment #0 by rburners — 2016-06-10T20:13:13Z
struct Foo { import std.array : empty; @property bool empty() { return true; } } unittest { Foo f; assert(f.empty); } Error: expression f.empty of type void does not have a boolean value It seams like the import of std.array.empty is shadowing the empty @property. Moving the import out of the struct fixes the problem.
Comment #1 by dlang-bugzilla — 2017-07-19T07:09:43Z
Worth noting that before https://github.com/dlang/dmd/pull/2417, the error message made a bit more sense: test.d(4): Error: function test.Foo.empty conflicts with alias test.Foo.empty at test.d(2) The current error message mentions that f.empty is of type void, which is misleading.
Comment #2 by b2.temp — 2019-03-30T13:58:04Z
Works with parens: assert(f.empty()); Because the compiler can figure out that empty() is a member func, beforehand. And @property can be dropped from the test case.
Comment #3 by razvan.nitu1305 — 2022-11-09T14:52:11Z
Not anymore. This code compiles now. Closing as WORKSFORME.