[Issue 8074] New: template-mixin example contradicts text

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 9 09:51:09 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8074

           Summary: template-mixin example contradicts text
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: websites
        AssignedTo: nobody at puremagic.com
        ReportedBy: tim.dolores at gmail.com


--- Comment #0 from Tim Smith <tim.dolores at gmail.com> 2012-05-09 09:52:31 PDT ---
The text says:

"If two different mixins are put in the same scope, and each define a
declaration with the same name, there is an ambiguity error when the
declaration is referenced"

However, the example *does* compile with no error, and runs the Bar.func()
method. Here is the exact code I'm using:

$ cat mix08.d
import std.stdio, std.exception;

/*
   If two different mixins are put in the same scope, and each define a
   declaration with the same name, there is an ambiguity error when the
   declaration is referenced:
 */

mixin template Foo() {
    int x = 5;
    void func(int x) { writeln("Foo.func(), x = ", x); }
}

mixin template Bar() {
    int x = 4;
    void func() { writeln("Bar.func(), x = ", x); }
}

mixin Foo;
mixin Bar;

void main() {
    //writefln("x = %d", x); // error, x is ambiguous
    /*
       The call to func() is ambiguous because Foo.func and Bar.func are in
       different scopes.
     */
    func();             // error, func is ambiguous
}

$ dmd|grep DMD
DMD64 D Compiler v2.059
$ dmd -w mix08.d
$ ./mix08
Bar.func(), x = 4
$ 


I don't know if the text is wrong, or if DMD is wrong.

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


More information about the Digitalmars-d-bugs mailing list