[Issue 2740] Template Mixins do not work as advertised

2015-06-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2740

Andrei Alexandrescu and...@erdani.com changed:

   What|Removed |Added

Version|D1  D2 |D2

--


[Issue 2740] Template Mixins do not work as advertised

2011-10-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2740


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||FIXED


--- Comment #8 from Walter Bright bugzi...@digitalmars.com 2011-10-13 
19:40:50 PDT ---
https://github.com/D-Programming-Language/dmd/commit/4081225e4407ca08d6c8f9a390e1bb6def057c29

https://github.com/D-Programming-Language/dmd/commit/73e600b38ec0fdcadd3855db4b0ccac53a451da0

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2740] Template Mixins do not work as advertised

2011-07-09 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2740


Kenji Hara k.hara...@gmail.com changed:

   What|Removed |Added

   Keywords||patch
 CC||k.hara...@gmail.com


--- Comment #7 from Kenji Hara k.hara...@gmail.com 2011-07-09 16:45:34 PDT ---
https://github.com/D-Programming-Language/dmd/pull/223

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2740] Template Mixins do not work as advertised

2011-02-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2740


akb...@gmail.com changed:

   What|Removed |Added

 CC||akb...@gmail.com


--- Comment #6 from akb...@gmail.com 2011-02-19 12:18:10 PST ---
(In reply to comment #4)
 Hum, I suspect the code above should not even compile. Instantiating the 
 mixin 
 is analogous to cutting and pasting the body of the template into the 
 location
 of the mixin. http://www.digitalmars.com/d/2.0/template-mixin.html
 Thus it should be the same as:
 
 class Foo : IFooable {
   bool foo() { return false; }
   bool foo() { return false; }
 }
 
 
 which should be a semantic error, I think. See
 http://d.puremagic.com/issues/show_bug.cgi?id=5312

From http://www.digitalmars.com/d/2.0/template-mixin.html: The declarations in
a mixin are ‘imported’ into the surrounding scope. If the name of a declaration
in a mixin is the same as a declaration in the surrounding scope, the
surrounding declaration overrides the mixin one. In other words, declarations
in the current scope always hide declarations in the mixin.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2740] Template Mixins do not work as advertised

2010-09-08 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2740


David Simcha dsim...@yahoo.com changed:

   What|Removed |Added

 CC||dsim...@yahoo.com
   Severity|normal  |critical


--- Comment #2 from David Simcha dsim...@yahoo.com 2010-09-08 10:40:17 PDT ---
This seems to happen iff the class is called from its interface handle:

import std.stdio;

interface IFooable {
  bool foo();
}

mixin template TFoo() {
  override bool foo() { return true; }
}

class Foo : IFooable {
  mixin TFoo;
  override bool foo() { return false; }
}

void go(IFooable p) {
  writeln(p.foo);
}

void main() {
  Foo p = new Foo();
  go(p);// true
  writeln(p.foo);   // false
  IFooable i = p;
  writeln(i.foo);   // true
}

Marking as critical because this is an extremely subtle wrong-code bug that can
lead to some pretty frustrating debugging.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2740] Template Mixins do not work as advertised

2010-09-08 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2740



--- Comment #3 from David Simcha dsim...@yahoo.com 2010-09-08 10:42:34 PDT ---
Oh yeah, doesn't happen for abstract classes either.  Looks like only the
interface vtbl info is wrong.

import std.stdio;

abstract class IFooable {
  abstract bool foo();
}

mixin template TFoo() {
  override bool foo() { return true; }
}

class Foo : IFooable {
  mixin TFoo;
  override bool foo() { return false; }
}

void go(IFooable p) {
  writeln(p.foo);
}

void main() {
  Foo p = new Foo();
  go(p);// false
  writeln(p.foo);   // false
  IFooable i = p;
  writeln(i.foo);   // false
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---