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/2368 https://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.
Comment #1 by k.hara.pg — 2014-09-27T05:13:20Z
(In reply to Kenji Hara from comment #0) > https://github.com/D-Programming-Language/dmd/pull/2368 Sorry it was incorrect PR url. Correct link is: https://github.com/D-Programming-Language/dmd/pull/2467
Comment #2 by k.hara.pg — 2014-09-27T05:21:41Z
Comment #3 by github-bugzilla — 2014-10-12T21:20:28Z
Commits pushed to master at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/cafc1d24d2f26d6e310bdeb89cd4dc8cd4a3057e fix Issue 13539 - Disallow optional template parameters with C-style syntax https://github.com/D-Programming-Language/dlang.org/commit/3b110153edaf850b0a4ad28026bbdc111896ae16 Merge pull request #664 from 9rnsr/fix_declaration Issue 13538 & 13539 - Improve variable declaration grammar for old C style syntax