Thread overview
[Issue 7722] New: Refuse normal functions to be used as properties
Mar 19, 2012
Kenji Hara
Mar 20, 2012
Kenji Hara
Mar 24, 2012
Kenji Hara
Mar 28, 2012
Walter Bright
March 18, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7722

           Summary: Refuse normal functions to be used as properties
           Product: D
           Version: unspecified
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2012-03-18 05:48:46 PDT ---
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;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7722


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
           Platform|x86                         |All
            Version|unspecified                 |D2
         OS/Version|Windows                     |All


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-03-19 07:58:56 PDT ---
https://github.com/D-Programming-Language/dmd/pull/817

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7722



--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-03-19 17:46:06 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7722



--- Comment #3 from github-bugzilla@puremagic.com 2012-03-19 21:57:24 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7722



--- Comment #4 from github-bugzilla@puremagic.com 2012-03-19 22:04:32 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7722



--- Comment #5 from github-bugzilla@puremagic.com 2012-03-19 22:25:33 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 24, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7722



--- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> 2012-03-24 00:24:18 PDT ---
Reposted same pull: https://github.com/D-Programming-Language/dmd/pull/830

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7722



--- Comment #7 from github-bugzilla@puremagic.com 2012-03-27 23:06:42 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7722


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


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