PATCH: Fix wording in error
Nick Lewycky
nlewycky at google.com
Thu Apr 30 23:08:52 PDT 2015
On 30 April 2015 at 19:14, Richard Smith <richard at metafoo.co.uk> wrote:
> On Thu, Apr 30, 2015 at 6:50 PM, Nick Lewycky <nlewycky at google.com> wrote:
>
>> The thing that the brackets go after is not always an unqualified-id
>> (testcase included). Switch the word for "name".
>>
>
> Seems reasonable. While we're here... a diagnostic should generally
> describe the problem before / instead of describing what we think is the
> right solution. So something like "unexpected brackets; to declare an
> array, put the brackets after the name" would seem better phrasing?
>
Ordinarily I agree, but not in this case. The error is that you put the
brackets here instead of there. There is no underlying error, we
unambiguously understand what you were trying to write but that simply
isn't what C++ says. That the brackets were unexpected here doesn't impart
any information if we're already saying the brackets need to go there
instead.
If we go down this road, I'd rather say "brackets are not allowed here; to
declare an array, put the brackets after the name" since that indicates
that we clearly and unambiguously understood it, C++ just wouldn't let us
compile it.
We could try to explain the grammar, ala. "brackets are a
trailing-type-specifier and must be placed after the name" but that seems
excess jargon.
I suppose we could say some form of "expected type specifier in
declaration; to declare an array, place the brackets after the name"? This
is the wording that I think has the best chance of being helpful if the
compiler and programmer have two entirely different ideas of what grammar
productions we've followed to get here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150430/a369772b/attachment.html>
More information about the cfe-commits
mailing list