[Issue 6400] New: opDispatch with WithStatement

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 29 08:31:04 PDT 2011


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: nobody at puremagic.com
        ReportedBy: zan77137 at nifty.com


--- Comment #0 from SHOO <zan77137 at 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: -------


More information about the Digitalmars-d-bugs mailing list