digitalmars.D.bugs - [Issue 4413] New: typeof(this) doesn't work in method template signature
- d-bugmail puremagic.com (54/54) Jul 01 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4413
- d-bugmail puremagic.com (31/31) Feb 06 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4413
- d-bugmail puremagic.com (10/10) Feb 06 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4413
- d-bugmail puremagic.com (12/12) Mar 30 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4413
- d-bugmail puremagic.com (8/12) Mar 31 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4413
- d-bugmail puremagic.com (6/6) Dec 21 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4413
- d-bugmail puremagic.com (12/12) Dec 21 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4413
- d-bugmail puremagic.com (13/13) Dec 26 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4413
- d-bugmail puremagic.com (10/10) Apr 23 2012 http://d.puremagic.com/issues/show_bug.cgi?id=4413
http://d.puremagic.com/issues/show_bug.cgi?id=4413 Summary: typeof(this) doesn't work in method template signature Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc dmd v2.047 shows a compilation error on the call to bar4, but in my opinion the compiler has to compile all four those bar methods: struct Foo { alias typeof(this) typeof_this; void bar1(typeof_this other) {} void bar2()(typeof_this other) {} void bar3(typeof(this) other) {} void bar4()(typeof(this) other) {} } void main() { Foo f; f.bar1(f); // OK f.bar2(f); // OK f.bar3(f); // OK f.bar4(f); // ERR } The generated errors: test.d(13): Error: template test.Foo.bar4() does not match any function template declaration test.d(13): Error: template test.Foo.bar4() cannot deduce template function from argument types !()(Foo) The problem of bar4 has shown up in D2 code similar to this one, where I have used typeof(this) to follow the DRY strategy and avoid repeating the struct name more than one time: struct Vec2 { float x, y; auto opBinary(string op)(typeof(this) other) if (op == "+") { ... } } A workaround that can be used is: struct Vec2 { float x, y; alias typeof(this) typeof_this; auto opBinary(string op)(typeof_this other) if (op == "+") { ... } } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 01 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4413 Iain Buclaw <ibuclaw ubuntu.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ibuclaw ubuntu.com Calling semantic on the param type in ::deduceType seems to be simplest workaround without causing side effects. --- a/src/template.c +++ b/src/template.c -2183,6 +2183,7 MATCH TypeStruct::deduceType(Scope *sc, Type *tparam, TemplateParameters *parame * to a template instance, too, and try again. */ TemplateInstance *ti = sym->parent->isTemplateInstance(); + tparam = tparam->semantic(0, sc); if (tparam && tparam->ty == Tinstance) { -2317,6 +2318,7 MATCH TypeClass::deduceType(Scope *sc, Type *tparam, TemplateParameters *paramet * to a template instance, too, and try again. */ TemplateInstance *ti = sym->parent->isTemplateInstance(); + tparam = tparam->semantic(0, sc); if (tparam && tparam->ty == Tinstance) { Ideally though, all typeof()'s should have been expanded beforehand. Regards -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 06 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4413 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |akb825 gmail.com *** Issue 5532 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 06 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4413 klickverbot <code klickverbot.at> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |code klickverbot.at --- The patch by Iain seems to break std.datetime: /usr/local/include/d2/std/datetime.d(9217): Error: template instance std.datetime.DTRebindable!(immutable(TimeZone)) error instantiating -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 30 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4413The patch by Iain seems to break std.datetime: /usr/local/include/d2/std/datetime.d(9217): Error: template instance std.datetime.DTRebindable!(immutable(TimeZone)) error instantiatingYep, I was merely suggesting that things should ideally be worked out before this point (because they *can* be worked out). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 31 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4413 *** Issue 5801 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 21 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4413 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid Platform|x86 |All OS/Version|Windows |All https://github.com/D-Programming-Language/dmd/pull/572 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 21 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4413 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |FIXED 18:26:35 PST --- https://github.com/D-Programming-Language/dmd/commit/8fa99fca73fea3a5130939ecaa83596f925cdbb8 https://github.com/D-Programming-Language/dmd/commit/2324c9903f99bb355ac5b2f25298a4f05ab0fba1 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 26 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4413 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kennytm gmail.com *** Issue 5903 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 23 2012