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

           Summary: opDispatch with WithStatement
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: zan77...@nifty.com


--- Comment #0 from SHOO <zan77...@nifty.com> 2011-07-29 08:31:01 PDT ---
Following code doesn't work:
----------------------------
import std.stdio;

class Foo
{
    void opDispatch(string name)()
    {
        writeln(name);
    }
}

void main()
{
    auto foo = new Foo;
    with (foo)
    {
        bar();
    }
}
----------------------------
Result:
$ dmd -run main
main.d(16): Error: undefined identifier bar

----------------------------


According to the specifications, WithStatement should be interpreted as
follows:
----
with (foo)
{
    bar();
}
---- is semantically equivalent to:
Foo tmp = foo;
tmp.bar();
---- is semantically equivalent to:
Foo tmp = foo;
tmp.opDispatch!("bar")();
----

It is incorrect behavior and is a bug. And another thing, this syntax is simply
convenient if I could use opDispatch in WithStatement.

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

Reply via email to