| Thread overview | |||||||
|---|---|---|---|---|---|---|---|
|
May 25, 2016 [Issue 16075] Compiler rejects basic mixin template | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=16075 b2.temp@gmx.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |b2.temp@gmx.com Resolution|--- |INVALID --- Comment #1 from b2.temp@gmx.com --- (In reply to Max Samukha from comment #0) > mixin template Foo(A...) { > static if (A.length) { > void foo(A[0] a) { > } > > mixin Foo!(A[1..$]) F; > alias foo = F.foo; > } > } > > mixin Foo!(int, string, bool); > > void main() { > } > > Error: alias test.Foo!(int, string, bool).Foo!(string, bool).Foo!bool.foo > recursive alias declaration > > > The mixin should produce properly nested overload sets of foo: > > foo(int); foo(string); foo(bool); > F.foo(string); F.foo(bool); > F.F.foo(bool); Hi, there is an error in your code, the correct way to write your template is: mixin template Foo(A...) { static if (A.length) { void foo(A[0] a) {} static if (A.length > 1) // here !! { mixin Foo!(A[1..$]) F; alias foo = F.foo; } } } mixin Foo!(int,string,bool); void main() {} | ||||
May 26, 2016 [Issue 16075] Compiler rejects basic mixin template | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=16075 --- Comment #2 from Max Samukha <maxsamukha@gmail.com> --- (In reply to b2.temp from comment #1) > > Hi, there is an error in your code, the correct way to write your template is: > > > > mixin template Foo(A...) > { > static if (A.length) > { > void foo(A[0] a) {} > static if (A.length > 1) // here !! > { > mixin Foo!(A[1..$]) F; > alias foo = F.foo; > } > } > } > > mixin Foo!(int,string,bool); > > void main() {} > > > > otherwise the instanciation continues endlessly with an empty A. No. The base case is when A.length is zero. Remove the alias, and the example will compile. -- | ||||
May 26, 2016 [Issue 16075] Compiler rejects basic mixin template | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=16075 Max Samukha <maxsamukha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID |--- -- | ||||
May 26, 2016 [Issue 16075] Compiler rejects basic mixin template | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=16075 Max Samukha <maxsamukha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution|--- |INVALID --- Comment #3 from Max Samukha <maxsamukha@gmail.com> --- Oops. You are right. In the original example, the wrong foo is aliased because the base case doesn't have one. -- | ||||
March 21, 2020 [Issue 16075] Compiler rejects basic mixin template | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=16075 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC|b2.temp@gmx.com | -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply