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.