[Issue 20431] New: Allow a Mixin Type to resolve to an expression where it makes sense
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Dec 5 11:30:15 UTC 2019
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 at puremagic.com
Reporter: boris2.9 at 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.
--
More information about the Digitalmars-d-bugs
mailing list