digitalmars.D.bugs - [Issue 9272] New: opDispatch conflicts with UFCS on template functions
- d-bugmail puremagic.com (25/25) Jan 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9272
- d-bugmail puremagic.com (20/20) Jan 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9272
- d-bugmail puremagic.com (18/19) Jan 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9272
- d-bugmail puremagic.com (8/26) Jan 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9272
- d-bugmail puremagic.com (8/30) Jan 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9272
- d-bugmail puremagic.com (21/33) Jan 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9272
- d-bugmail puremagic.com (7/37) Jan 06 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9272
http://d.puremagic.com/issues/show_bug.cgi?id=9272 Summary: opDispatch conflicts with UFCS on template functions Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: dransic gmail.com --- struct Foo { void opDispatch(string s)() {} } void bar(T)(Foo f) {} unittest { Foo foo; bar!int(foo); // OK foo.bar!int(); // Error: foo.opDispatch isn't a template } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9272 Nils <nilsbossung googlemail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |nilsbossung googlemail.com Resolution| |INVALID --- No bug here, I think. opDispatch takes precedence and just fails to compile. The same thing happens with --- struct Foo { void bar() {} } --- The error message could be improved though. foo.opDispatch is a template. It's foo.opDispatch!"bar" that is not. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9272 ---opDispatch takes precedence and just fails to compile.Obviously. But is it really by design? This works, where opDispatch does not take precedence: --- struct Foo { void opDispatch(string s)() {} } void baz(Foo f) {} unittest { Foo foo; foo.baz(); // OK } --- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9272Just *template* opDispach is required for operator overloading. Therefore non-template function is simply ignored. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------opDispatch takes precedence and just fails to compile.Obviously. But is it really by design? This works, where opDispatch does not take precedence: --- struct Foo { void opDispatch(string s)() {} } void baz(Foo f) {} unittest { Foo foo; foo.baz(); // OK } ---
Jan 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9272 ---Yes. I understand why it doen't work at the moment. I just found it inconsistent. Maybe this should be an enhancement request then... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Just *template* opDispach is required for operator overloading. Therefore non-template function is simply ignored.opDispatch takes precedence and just fails to compile.Obviously. But is it really by design? This works, where opDispatch does not take precedence: --- struct Foo { void opDispatch(string s)() {} } void baz(Foo f) {} unittest { Foo foo; foo.baz(); // OK } ---
Jan 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9272 Simen Kjaeraas <simen.kjaras gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |simen.kjaras gmail.com PST ---This works, where opDispatch does not take precedence: --- struct Foo { void opDispatch(string s)() {} } void baz(Foo f) {} unittest { Foo foo; foo.baz(); // OK }Except, of course, opDispatch *does* take precedence here. Try this instead: import std.stdio : writeln; struct Foo { void opDispatch(string s)() { writeln("opDispatch: ", s); } } void baz(Foo f) { writeln("function: baz"); } void main( ) { Foo foo; foo.baz(); // OK } I can assure you it prints opDispatch: baz. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9272 ---Ah! I was trapped by the minimalism of my example. OK thanks. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------This works, where opDispatch does not take precedence: --- struct Foo { void opDispatch(string s)() {} } void baz(Foo f) {} unittest { Foo foo; foo.baz(); // OK }Except, of course, opDispatch *does* take precedence here. Try this instead: import std.stdio : writeln; struct Foo { void opDispatch(string s)() { writeln("opDispatch: ", s); } } void baz(Foo f) { writeln("function: baz"); } void main( ) { Foo foo; foo.baz(); // OK } I can assure you it prints opDispatch: baz.
Jan 06 2013