Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 28, 2012 [Issue 9235] New: Template mixin makes doesn't allow to mixin in non-conflicting overloads | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2012-12-28 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: ------- |
December 28, 2012 [Issue 9235] Template mixin doesn't allow to mixin non-conflicting overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | http://d.puremagic.com/issues/show_bug.cgi?id=9235 --- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-12-28 05:55:08 PST --- 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: ------- |
January 30, 2013 [Issue 9235] Template mixin doesn't allow to mixin non-conflicting overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | http://d.puremagic.com/issues/show_bug.cgi?id=9235 Maksim Zholudev <maximzms@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maximzms@gmail.com --- Comment #2 from Maksim Zholudev <maximzms@gmail.com> 2013-01-30 05:49:59 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: ------- |
February 04, 2013 [Issue 9235] Template mixin doesn't allow to mixin non-conflicting overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | http://d.puremagic.com/issues/show_bug.cgi?id=9235 --- Comment #3 from Maksim Zholudev <maximzms@gmail.com> 2013-02-04 08:12:40 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: ------- |
February 14, 2013 [Issue 9235] Template mixin doesn't allow to mixin non-conflicting overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | http://d.puremagic.com/issues/show_bug.cgi?id=9235 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2013-02-14 08:06:47 PST --- 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: ------- |
February 14, 2013 [Issue 9235] Template mixin doesn't allow to mixin non-conflicting overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | http://d.puremagic.com/issues/show_bug.cgi?id=9235 --- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> 2013-02-14 08:15:38 PST --- (In reply to comment #3) > Signature constraints are ignored also for structures: [snip] It is not valid code, because > struct 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: ------- |
February 14, 2013 [Issue 9235] Template mixin doesn't allow to mixin non-conflicting overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | 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 --- Comment #6 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-14 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: ------- |
July 17, 2013 [Issue 9235] Template mixin doesn't allow to mixin non-conflicting overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | http://d.puremagic.com/issues/show_bug.cgi?id=9235 --- Comment #7 from github-bugzilla@puremagic.com 2013-07-16 18:36:00 PDT --- 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 Merge pull request #1660 from 9rnsr/fix1900 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: ------- |
July 17, 2013 [Issue 9235] Template mixin doesn't allow to mixin non-conflicting overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | 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 --- Comment #8 from Kenji Hara <k.hara.pg@gmail.com> 2013-07-17 00:05:02 PDT --- Template overload set has been implemented in git head. But, the case in comment#2 does not yet work. 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: ------- |
Copyright © 1999-2021 by the D Language Foundation