Bug 14978 – Improve incorrect AA declaration error message
Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-08-30T00:58:54Z
Last change time
2022-10-10T09:11:33Z
Assigned to
No Owner
Creator
Luís Marques
Comments
Comment #0 by luis — 2015-08-30T00:58:54Z
Code:
void main()
{
(const(char)*)[string] aa;
}
Error messages:
test.d(3): Error: (arguments) expected following const(char)
test.d(3): Error: expression expected, not ')'
test.d(3): Error: found 'aa' when expecting ')'
It would be nice if the error messages were clearer (and more precise).
Comment #1 by razvan.nitu1305 — 2022-10-10T09:11:33Z
Unfortunately, I don't think this can be fixed. Once you have `()` the compiler expects an expression. If you have a type, it simply treats the expression as a cast. However, the parser does not exactly if you have a type or not inside the params, it just checks what's next after `)`. I tried fixing it by checking whether after `)` we have a left bracket (`[`) [1], but that is not enough, because we need more context than this (namely, we need to know if we had a type or not inside the parens, but that is available only at semantic time).
That is why I think that this is WONTFIX bug report.
[1] https://github.com/dlang/dmd/pull/14544