D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6738 - Can't call templatized property function from within a struct/class method
Summary: Can't call templatized property function from within a struct/class method
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 major
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2011-09-27 17:37 UTC by Andrej Mitrovic
Modified: 2012-02-17 20:20 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-09-27 17:37:44 UTC
struct Foo
{
    int _val;
    
    @property int val()() { return _val; }
    int get() { return val; }  // fail
}
    
void main()
{
    Foo bar;
    auto x = bar.val;  // ok
}

Error: cannot implicitly convert expression (val()) of type void to int

Note how I can call the property function without errors from outside Foo's methods, however from inside its methods I can't.

The *real* issue here is that I can't overload templated and non-templated functions. In my own code I have a templated setter and want to use a non-templated getter. However that can't work right now due to bugs, so I'm forced to make the getter a template by adding an empty set of parens. 

But as you can see, this introduces yet another new bug. :/
Comment 2 Andrej Mitrovic 2011-10-08 15:15:07 UTC
It's absolutely fantastic that this is getting fixed. Major props!
Comment 3 github-bugzilla 2012-01-26 12:06:13 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/1d4438f151143fcdcb807e257959dd1d588f9048
Issue 6738 - Can't call templatized property function from within a struct/class method
Comment 4 Walter Bright 2012-02-14 00:31:41 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/de89294e9ed1842c9fc36b5ce0d37cfc14952238
revert commit 1d4438f, fix bug 7498, reopen bug 6738
Comment 6 github-bugzilla 2012-02-17 19:39:46 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/63dd3e18b32acaf31da81d91bbb10ea8b2aa0651
Merge pull request #715 from 9rnsr/fix6738

fix issue 6738 revisited