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

Jonathan M Davis newsgroup.d at jmdavisprog.com
Thu Jan 3 02:25:57 UTC 2019


On Wednesday, January 2, 2019 6:31:31 PM MST Neia Neutuladh via Digitalmars-
d wrote:
> On Wed, 02 Jan 2019 20:20:12 +0000, Bastiaan Veelo wrote:
> > What I find misleading is "only one index allowed" because `[1][1]` are
> > two indices and clearly allowed.
>
> int[3][3] only allows one index. The value this yields is an int[3], which
> in turn only allows one index. But that's cutting hairs pretty fine.

As with many error messages, the message is very much correct, but some
folks may find in confusing. Given that error messages tend to be written
from the standpoint of what the compiler sees rather than from what the
programmer meant, it can be a bit difficult to write good error messages
that really help a confused developer figure out what's wrong with their
code. But creating enhancement requests in bugzilla whenever you find an
error message confusing can lead to improved error messages. Without that,
it's unlikely that such messages will ever be improved.

- Jonathan M Davis





More information about the Digitalmars-d mailing list