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)
```

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 can solve this by importing std.array: empty in the method instead of the struct, but for my understanding of import statements in structs I'd appreciate if someone explained what these errors mean and why exactly they occur.

Thanks.

Reply via email to