Bug 20431 – Allow a Mixin Type to resolve to an expression where it makes sense

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-12-05T11:30:15Z
Last change time
2019-12-09T10:26:05Z
Keywords
pull
Assigned to
No Owner
Creator
Boris Carvajal

Comments

Comment #0 by boris2.9 — 2019-12-05T11:30:15Z
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.
Comment #1 by dlang-bot — 2019-12-05T11:42:28Z
@BorisCarvajal updated dlang/dmd pull request #10629 "Better fix for issue 20388" fixing this issue: - Fix issue 20431 - Allow a Mixin Type to resolve to an expression https://github.com/dlang/dmd/pull/10629
Comment #2 by dlang-bot — 2019-12-09T10:26:05Z
dlang/dmd pull request #10629 "Fix issue 20431 - Allow a Mixin Type to resolve to an expression" was merged into stable: - ece7f2cd978ab5e2138f0ccdcf176aaebebde569 by Boris Carvajal: Fix issue 20431 - Allow a Mixin Type to resolve to an expression https://github.com/dlang/dmd/pull/10629