digitalmars.D.bugs - DMD 0.95: mixins don't allow overriding by base symbols in a type
- Burton Radons (21/21) Jul 18 2004 This code fails compilation with the error code:
- Derek Parnell (11/32) Jul 19 2004 This is not a mixin bug. It's not really a bug either, I think.
- Ivan Senji (7/39) Jul 19 2004 Not a strange message. You should give a mixin a name to do that:
- Derek (5/52) Jul 19 2004 Ahhh...of course! Thanks, Ivan.
- Andrew (10/25) Jul 19 2004 Absolutely unnecessary: unless you need to have multiple ways of referri...
- Andrew (9/19) Jul 19 2004 When Mixed_in, the contents of a template becomes local to the class, th...
- Ivan Senji (4/26) Jul 19 2004 I don't understand why this works? Isn't class name only used to acces
- Burton Radons (6/12) Jul 19 2004 "If the name of a declaration in a mixin is the same as a declaration in...
- Walter (5/17) Jul 30 2004 still
This code fails compilation with the error code: foo.d(20): cannot implicitly convert char[5] to int The "x" symbol in the template should not be mixed in because it already exists in the scope. This is the code: template t () { int x; } class a { char [] x; } class b : a { mixin t; } void main () { b n; n.x = "hello"; // error: cannot implicitly convert char[5] to int }
Jul 18 2004
On Sun, 18 Jul 2004 23:46:24 -0700, Burton Radons wrote:template t () { int x; } class a { char [] x; } class b : a { mixin t; } void main () { b n; n.x = "hello"; // error: cannot implicitly convert char[5] to int }This is not a mixin bug. It's not really a bug either, I think. n.a.x = "hello"; // Works fine. If you don't use a mixin and just code the "int x;" explicitly, you still get the same message. I tried using n.t.x = 1; but that threw out a different (and strange) message ... "test.d(24): no property 't' for type 'b'". -- Derek Melbourne, Australia 19/Jul/04 5:00:32 PM
Jul 19 2004
"Derek Parnell" <derek psych.ward> wrote in message news:cdfsnj$5hv$1 digitaldaemon.com...On Sun, 18 Jul 2004 23:46:24 -0700, Burton Radons wrote:Not a strange message. You should give a mixin a name to do that: Like mixin t T; ... n.T.x = 1;template t () { int x; } class a { char [] x; } class b : a { mixin t; } void main () { b n; n.x = "hello"; // error: cannot implicitly convert char[5] to int }This is not a mixin bug. It's not really a bug either, I think. n.a.x = "hello"; // Works fine. If you don't use a mixin and just code the "int x;" explicitly, you still get the same message. I tried using n.t.x = 1; but that threw out a different (and strange) message ... "test.d(24): no property 't' for type 'b'".-- Derek Melbourne, Australia 19/Jul/04 5:00:32 PM
Jul 19 2004
On Mon, 19 Jul 2004 11:32:23 +0200, Ivan Senji wrote:"Derek Parnell" <derek psych.ward> wrote in message news:cdfsnj$5hv$1 digitaldaemon.com...Ahhh...of course! Thanks, Ivan. -- Derek Melbourne, AustraliaOn Sun, 18 Jul 2004 23:46:24 -0700, Burton Radons wrote:Not a strange message. You should give a mixin a name to do that: Like mixin t T; ... n.T.x = 1;template t () { int x; } class a { char [] x; } class b : a { mixin t; } void main () { b n; n.x = "hello"; // error: cannot implicitly convert char[5] to int }This is not a mixin bug. It's not really a bug either, I think. n.a.x = "hello"; // Works fine. If you don't use a mixin and just code the "int x;" explicitly, you still get the same message. I tried using n.t.x = 1; but that threw out a different (and strange) message ... "test.d(24): no property 't' for type 'b'".-- Derek Melbourne, Australia 19/Jul/04 5:00:32 PM
Jul 19 2004
In article <cdg4fa$80i$1 digitaldaemon.com>, Ivan Senji says..."Derek Parnell" <derek psych.ward> wrote in messageAbsolutely unnecessary: unless you need to have multiple ways of referring to the same thing (aka alias). With your example above I can do: void main () { b n = new b; //Otherwise you get a runtime Access Violation error n.a.x = "hello"; n.x = 777; printf("%d",n.T.x); }This is not a mixin bug. It's not really a bug either, I think. n.a.x = "hello"; // Works fine. If you don't use a mixin and just code the "int x;" explicitly, you still get the same message. I tried using n.t.x = 1; but that threw out a different (and strange) message ... "test.d(24): no property 't' for type 'b'".Not a strange message. You should give a mixin a name to do that: Like mixin t T; ... n.T.x = 1;
Jul 19 2004
This is not a mixin bug. It's not really a bug either, I think. n.a.x = "hello"; // Works fine. If you don't use a mixin and just code the "int x;" explicitly, you still get the same message. I tried using n.t.x = 1; but that threw out a different (and strange) message ... "test.d(24): no property 't' for type 'b'".When Mixed_in, the contents of a template becomes local to the class, thus granting access to a "local" int x. Try: void main () { b n = new b; //Otherwise you get a runtime Access Violation error n.a.x = "hello"; n.x = 1; }-- Derek Melbourne, Australia 19/Jul/04 5:00:32 PM
Jul 19 2004
"Andrew" <Andrew_member pathlink.com> wrote in message news:cdh15p$jnt$1 digitaldaemon.com...I don't understand why this works? Isn't class name only used to acces static members? Or can it be used to acces super class members too?This is not a mixin bug. It's not really a bug either, I think. n.a.x = "hello"; // Works fine. If you don't use a mixin and just code the "int x;" explicitly, you still get the same message. I tried using n.t.x = 1; but that threw out a different (and strange) message ... "test.d(24): no property 't' for type 'b'".When Mixed_in, the contents of a template becomes local to the class, thus granting access to a "local" int x. Try: void main () { b n = new b; //Otherwise you get a runtime Access Violation error n.a.x = "hello";n.x = 1; }-- Derek Melbourne, Australia 19/Jul/04 5:00:32 PM
Jul 19 2004
Derek Parnell wrote:This is not a mixin bug. It's not really a bug either, I think. n.a.x = "hello"; // Works fine. If you don't use a mixin and just code the "int x;" explicitly, you still get the same message."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." If the scope is limited to being the immediate scope, and not include any nesting scope or dependent scope, fine. But that's not how the standard is written now.
Jul 19 2004
"Burton Radons" <burton-radons shaw.ca> wrote in message news:cdh4i5$l2h$1 digitaldaemon.com...Derek Parnell wrote:stillThis is not a mixin bug. It's not really a bug either, I think. n.a.x = "hello"; // Works fine. If you don't use a mixin and just code the "int x;" explicitly, youBase class members are in a different scope. But I agree the wording could be better.get the same message."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." If the scope is limited to being the immediate scope, and not include any nesting scope or dependent scope, fine. But that's not how the standard is written now.
Jul 30 2004