D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6858 - opDispatch is unusable for property functions
Summary: opDispatch is unusable for property functions
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-26 21:04 UTC by Andrej Mitrovic
Modified: 2014-03-19 21:30 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2011-10-26 21:04:04 UTC
struct Foo
{
    @property void x(int) {}
}

struct Bar
{
    Foo foo;
    
    void opDispatch(string Field, Args...)(Args args)
    {
        foo.x = args;
    }
}

void main()
{
    Bar bar;
    bar.x = 5;
}

Error: expected 1 function arguments, not 0

Of course there's no way DMD can tell in advance that opDispatch will invoke a property function, so it just expects opDispatch to return an lvalue to be assigned with 5. :/
Comment 1 Infiltrator 2014-03-19 21:30:13 UTC
The provided code compiles and runs as of v2.065.