Bug 13539 – Disallow optional template parameters with C-style syntax
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-09-27T05:09:00Z
Last change time
2014-10-12T21:20:29Z
Keywords
pull, spec
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2014-09-27T05:09:03Z
When I improved DIP42 feature, I didn't consider the combination with C-style syntax.
https://github.com/D-Programming-Language/dmd/pull/2368https://github.com/D-Programming-Language/dlang.org/pull/371
Current grammar accepts the optional template parameters always, even if the DeclaratorSuffixes is not empty.
Declarator:
BasicType2_opt ( Declarator ) DeclaratorSuffixes_opt
BasicType2_opt Identifier DeclaratorSuffixes_opt
[snip]
DeclaratorSuffix:
[ ]
[ AssignExpression ]
[ Type ]
Parameters MemberFunctionAttributes_opt
TemplateParameters Parameters MemberFunctionAttributes_opt Constraint_opt
Because of the fact, current dmd accepts follwing syntax.
string results[](T) = "I have no idea what I'm doing";
It was mentioned in the thread: http://forum.dlang.org/post/[email protected]
I think we need to disallow such syntax to recommend proper D style declaration.