www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20431] New: Allow a Mixin Type to resolve to an expression

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

          Issue ID: 20431
           Summary: Allow a Mixin Type to resolve to an expression where
                    it makes sense
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: boris2.9 gmail.com

When Mixin Types were introduced in the grammar they took over Mixin
Expressions in a few places in the parser such as in template parameters or
array declarations.

This code stopped working

    fun!(mixin("(a) => ++a"))();    // void fun(alias t)(){}
    int[mixin("4")] b;
    auto c = new int[mixin("4")];

and the following started to work

    fun!(mixin("MyType"))();
    int[mixin("string")] d;

However, with the fix to issue 20388, mixins in template arguments were
restored back to be parsed as expressions to not break code.

A more consistent solution would be to allow both a type or an expression in
Mixin Types specially for the template argument case.

--
Dec 05 2019