www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22613] New: Alias to template instantiation can act as the

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

          Issue ID: 22613
           Summary: Alias to template instantiation can act as the
                    template itself
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: hagai weka.io

Example:
```
enum foo(int x) = x;
alias bar = foo!1;

pragma(msg, bar);   // prints 1
pragma(msg, bar!2); // prints 2
```

`bar` is an alias to instantiated template (an `int` value), yet surprisingly
it can also act as the template itself, and be re-instantiated. I'd expect the
expression `bar!2` to produce a compilation error.

--
Dec 20 2021