[Issue 13539] New: Disallow optional template parameters with C-style syntax

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Sep 26 22:09:03 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13539

          Issue ID: 13539
           Summary: Disallow optional template parameters with C-style
                    syntax
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: k.hara.pg at gmail.com

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/kjodgiflvnqaazyyawsm@forum.dlang.org

I think we need to disallow such syntax to recommend proper D style
declaration.

--


More information about the Digitalmars-d-bugs mailing list