Bug 12022 – Spurious "recursive alias declaration" with lambdas as template parameters

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-28T23:50:00Z
Last change time
2015-06-23T05:46:35Z
Keywords
rejects-valid
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2014-01-28T23:50:21Z
/////////////////////////////////// struct S(alias F) { } int f(); alias A() = S!(() => f()); A!() a; /////////////////////////////////// The recursive alias semantic is triggered by Expression::checkPurity (which calls getFuncTemplateDecl -> toAlias). Workaround: redeclare lambdas as templated functions in an eponymous template, and make sure that they do not refer to the outer template arguments (they must be passed to the templated functions in the alias declaration). Example: template A(string x) { auto f(string y)() { return p(y); } alias A = S!(f); }
Comment #1 by k.hara.pg — 2015-06-23T05:46:35Z
(In reply to Vladimir Panteleev from comment #0) > The recursive alias semantic is triggered by Expression::checkPurity (which > calls getFuncTemplateDecl -> toAlias). It's fixed from 2.066, by the commit: https://github.com/D-Programming-Language/dmd/commit/33f2ab82bd9fb51d88927b8048d88c30ea44111e