www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16399] New: template with func. ptr. argument and anon. func.

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

          Issue ID: 16399
           Summary: template with func. ptr. argument and anon. func. in
                    the template body, rejects its argument
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: cauterite gmail.com

( https://dpaste.dzfl.pl/79301f12e5fc )

// ------ Example: ----------

template A(alias Arg) {
    enum A = Arg;
    enum Unrelated = ({return 0;})(); // Error: expression & asdf is not a
valid template value argument
};

void main() {
    enum FnPtr = &asdf;
    enum _ = A!FnPtr;
};

void asdf() {};

// ------------------

remove the "enum Unrelated =" line and it compiles fine.
this also compiles fine: https://dpaste.dzfl.pl/fca15065a4cf

--
Aug 17 2016