Thread overview
[Issue 5039] New: Cannot use invariant() with auto methods
Oct 11, 2010
Austin Hastings
Jul 14, 2011
Kenji Hara
Jan 29, 2012
yebblies
May 03, 2012
Walter Bright
October 11, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5039

           Summary: Cannot use invariant() with auto methods
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: ah08010-d@yahoo.com


--- Comment #0 from Austin Hastings <ah08010-d@yahoo.com> 2010-10-11 01:04:38 PDT ---
This code:
==========
module scratch;

class C {
    int x;

    invariant() {
        assert( x < int.max );
    }

    auto foo() {
        return x;
    }
}
=========
Reports this error:
$ dmd scratch.d
scratch.d(10): Error: function scratch.C.foo post conditions are not supported
if the return type is inferred

Removing the invariant eliminates the error message. Converting the 'auto' to an explicit return type eliminates the error message.

Given that the compiler must eventually figure out the return type of the method, I have no idea why this error is occurring.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5039


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, rejects-valid
                 CC|                            |k.hara.pg@gmail.com


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2011-07-14 04:29:09 PDT ---
https://github.com/D-Programming-Language/dmd/pull/147

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


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com
           Platform|x86                         |All
             Blocks|                            |7337
         OS/Version|Windows                     |All
           Severity|minor                       |normal


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



--- Comment #2 from github-bugzilla@puremagic.com 2012-05-02 18:25:34 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/007b936e0970666c7698ad7c3b2c2b3da2d8cbc0 Merge pull request #147 from 9rnsr/fix4785

Issue 4785 & 5039 Allow auto return function with contracts

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


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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