digitalmars.D.bugs - [Issue 9235] New: Template mixin makes doesn't allow to mixin in non-conflicting overloads
- d-bugmail puremagic.com (72/72) Dec 28 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9235
- d-bugmail puremagic.com (20/20) Dec 28 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9235
- d-bugmail puremagic.com (39/39) Jan 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9235
- d-bugmail puremagic.com (31/31) Feb 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9235
- d-bugmail puremagic.com (10/10) Feb 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9235
- d-bugmail puremagic.com (20/30) Feb 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9235
- d-bugmail puremagic.com (12/12) Feb 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9235
- d-bugmail puremagic.com (12/12) Jul 16 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9235
- d-bugmail puremagic.com (14/14) Jul 17 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9235
http://d.puremagic.com/issues/show_bug.cgi?id=9235 Summary: Template mixin makes doesn't allow to mixin in non-conflicting overloads Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: dmitry.olsh gmail.com 04:55:48 PST --- The program below show the problem. If it was by design then design is faulty as the broken error message indicates. (I have a real-world use case for this and see no reason to forbid it) enum Command{ Char, Any, Fork, Jump, End }; template FlowEvaluator() { //if control flow bool execute(Command cmd)() if(cmd == Command.Jump || cmd == Command.Fork) { return false; } } template MatchEvaluator() { //if operation bool execute(Command cmd)() if(cmd == Command.Char || cmd == Command.Any || cmd == Command.End) { return false; } } struct Machine { mixin FlowEvaluator; mixin MatchEvaluator; bool exec() { return execute!(Command.Any)(); } } Fails with: mixin.d(36): Error: template instance execute!(cast(Command)1) ambiguous template declaration mixin.Machine.MatchEvaluator!().execute(Command cmd)() if (cmd == Command.Char || cmd == Command.Any || cmd == Command.End) and mixin.Machine.FlowEvaluator!().execute(Command cmd)() if (cmd == Command.Jump || cmd == Command.Fork) mixin.d(36): Error: template instance execute!(cast(Command)1) execute!(cast(Command)1) does not match template declaration execute(Command cmd)() if (cmd == Command.Jump || cmd == Command.Fork) mixin.d(36): Error: function expected before (), not execute!(cast(Command)1) of type void The second message hints to me that compiler in fact knows perfectly well which one template does match the instantiation but something prevented it from just picking it. Tested on 2.061alpha, I think it was there all along. Marking as major as there is either bogus diagnostic or a broken feature. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 28 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9235 This is a kind of "template overload set", which is not yet supported in current dmd. Following is an another case which fails to compile based on the same issue. --- // module a; template A(T) if (is(T == int)) {} // module b; template A(T) if (is(T == double)) {} // moudle test; import a, b; alias A!int X; --- output: test.d(5): Error: template instance A!(int) ambiguous template declaration b.A(T) if (is(T == double)) and a.A(T) if (is(T == int)) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 28 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9235 Maksim Zholudev <maximzms gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maximzms gmail.com PST --- http://dlang.org/template-mixin.html "Alias declarations can be used to overload together functions declared in different mixins" Unfortunately this doesn't work: ------------------- mixin template mixA() { void foo(string s)() if(s == "a") {} } mixin template mixB() { void foo(string s)() if(s == "b") {} } struct Foo { mixin mixA A; mixin mixB B; alias A.foo foo; alias B.foo foo; } void main() { Foo f; f.foo!"a"(); } ------------------- test.d(16): Error: alias test.Foo.foo conflicts with alias test.Foo.foo at test.d(15) ------------------- It looks like signature constraints are ignored in this case. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 30 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9235 PST --- Signature constraints are ignored also for structures: ------------------- struct A { void foo(string s)() if(s == "a") {} } struct B { void foo(string s)() if(s == "b") {} } struct Foo { A a; B b; alias a.foo foo; alias b.foo foo; } void main() { Foo f; f.foo!"a"(); } ------------------- test.d(16): Error: alias test.Foo.foo conflicts with alias test.Foo.foo at test.d(15) ------------------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 04 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9235 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull https://github.com/D-Programming-Language/dmd/pull/1660 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9235Signature constraints are ignored also for structures:[snip] It is not valid code, becausestruct Foo { A a; B b; alias a.foo foo; alias b.foo foo; }is just same as: struct Foo { A a; B b; alias A.foo foo; // alias doesn't handle context *expression* alias B.foo foo; // so 'a' and 'b' are simply truncated. } Then,Foo f; f.foo!"a"();is identical with: A.foo!"a"(); But A.foo requires a valid 'this' expression, so compilation fails. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9235 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com 08:20:42 PST --- Is this related to http://d.puremagic.com/issues/show_bug.cgi?id=8074 ? Because it seems like overloading via template mixins is something Andrei wants to ban (I disagree with it). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9235 Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/cfe5b6c97c7a4db75f173768db407c6cb8007e30 fix Issue 9235 - Template mixin doesn't allow to mixin non-conflicting overloads https://github.com/D-Programming-Language/dmd/commit/cc6b7372f2efffd4c5c0314373af3b595ba06a2c Issue 1900 & 8352 & 9235 - Implement Template Overload Set -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 16 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9235 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid Status|NEW |RESOLVED Resolution| |FIXED Template overload set has been implemented in git head. For the remain issue I opened bug 10658. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 17 2013