Confusing "Error: only one index allowed to index [...]"

Steven Schveighoffer schveiguy at gmail.com
Wed Jan 2 22:49:45 UTC 2019


On 1/2/19 5:08 PM, Steven Schveighoffer wrote:

> In general, the fact that the compiler jumps right to trying the alias 
> this for certain things, and ignores the original type is a problem. It 
> comes up again and again. I don't think it's simply an indexing problem.
> 

Actually, I take this back. This is the correct error.

What is happening is the compiler is evaluating expressions:

a[1] resolves just fine, because of the int[] alias this. But then you 
are trying to index the result, which is an int.

So no, this error cannot be improved, and my initial analysis is wrong 
-- the compiler is not not jumping to the alias this incorrectly.

-Steve


More information about the Digitalmars-d mailing list