On 03/04/2018 08:17 PM, Dennis wrote:
I was making a stack interface for an array:
```
struct Stack(T) {
import std.array: empty;
T[] stack;
alias stack this;
}
void main()
{
Stack!int stack;
bool x = stack.empty;
}
```
My expectation is that you can now call `empty` on a stack instance
since I imported it in the struct, but it gives this error:
```
Error: cannot resolve type for stack.empty(T)(auto ref scope const(T) a)
if (is(typeof(a.length) : size_t) || isNarrowString!T)
```
`stack.empty` is an alias of `std.array.empty`. It's not a method of the
struct. It's not a UFCS call to `std.array.empty`.
You can call it this way: `stack.empty(stack)`. You can also call it
this way: `Stack!int.empty(stack)`. Maybe that makes it more obvious
what's going on.
When adding this method to the struct:
```
bool empty() {return stack.empty;}
```
I get this confusing error:
```
Error: expression stack.empty is void and has no value
```
I don't know what's going on here. The error message doesn't make sense
to me. Might be a bug in the compiler.