Bug 7722 – Refuse normal functions to be used as properties

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-18T05:48:00Z
Last change time
2012-03-28T12:02:33Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-03-18T05:48:46Z
I think this is a regression. It was introduced by fixing bug 7670. See that for more info. This code compiles with no errors with DMD 2.059head using the -property switch: class Foo {} void spam(Foo f) {} void main() { auto f = new Foo; f.spam; }
Comment #1 by k.hara.pg — 2012-03-19T07:58:56Z
Comment #2 by k.hara.pg — 2012-03-19T17:46:06Z
Enforce all @property attribute for property usage (with -property switch) is good, but one problem is in there. From: https://github.com/D-Programming-Language/dmd/pull/817#issuecomment-4580804 https://github.com/D-Programming-Language/dmd/pull/817#issuecomment-4586905 > With UFCS, a property setting e1.prop = ev is rewritten to .prop(e1, ev). > If the compiler disallows a property function with two arguments, we cannot > set @property attribute to .prop function, but -property switch enforce to > .prop that has @property. After all, we can never use such a syntax. @property void prop(int, int){} // Error: properties can only have zero or one parameter void main(){ 1.prop = 10; } > The alternate way is to stop property enforcement for the UFCS setter that > needs two arguments. /*@property */void prop(int, int){} void main(){ 1.prop = 10; } // not detected attribute missing with -property ---- Currently, my pull in comment#1 allows a property function that has two arguments.
Comment #3 by github-bugzilla — 2012-03-19T21:57:24Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/a57a29cf4a3631154c29e64c9377418893b36698 Merge pull request #817 from 9rnsr/fix_ufcs Issue 7722 - Refuse normal functions to be used as properties
Comment #4 by github-bugzilla — 2012-03-19T22:04:32Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/cc28ed074548ed6e8f5cf0d2f2a422b41ff51581 Revert "fix Issue 7722 - Refuse normal functions to be used as properties" This reverts commit ddd8f3456207ed4b94fb36fde9538e37eac36687.
Comment #5 by github-bugzilla — 2012-03-19T22:25:33Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/e1d932a56c80ea8d5f4adad85df648c71314f187 fix Issue 7722 - Refuse normal functions to be used as properties https://github.com/D-Programming-Language/dmd/commit/55e2a21b43a585cc3175542c0a89c17785631773 Revert "fix Issue 7722 - Refuse normal functions to be used as properties" This reverts commit ddd8f3456207ed4b94fb36fde9538e37eac36687.
Comment #6 by k.hara.pg — 2012-03-24T00:24:18Z
Comment #7 by github-bugzilla — 2012-03-27T23:06:42Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/29fa5e260ff5a56ac4716aa67840e0d4fd175a69 Merge pull request #830 from 9rnsr/fix_ufcs Issue 7722 - Refuse normal functions to be used as properties