Thread overview
[Issue 2933] New: Cannot return const/immutable with contracts (out/invariant) enabled
May 04, 2009
d-bugmail
May 10, 2009
Shin Fujishiro
Jun 04, 2009
Sobirari Muhomori
Jun 10, 2009
Sobirari Muhomori
May 14, 2010
Don
Jun 05, 2010
Don
May 04, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2933

           Summary: Cannot return const/immutable with contracts
                    (out/invariant) enabled
           Product: D
           Version: 2.029
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: tekjig@gmail.com


If a method of a class returns a const or immutable value, and the class has class invariant, then the compile fails.  It also fails if a method returning a const/immutable has an out contract.

The following code:
--------------------
class Foo
{
    invariant() {}
    const(int) foo()
    {
        return 0;
    }
    immutable(int) bar()
    out(abc) { }
    body
    {
        return 0;
    }
}
--------------------
causes this compile error:
--------------------
test.d(4): Error: variable test.Foo.foo.__result cannot modify const
test.d(9): Error: variable test.Foo.bar.abc cannot modify mutable
--------------------


-- 

May 10, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2933





--- Comment #1 from Shin Fujishiro <rsinfu@gmail.com>  2009-05-10 15:17:32 PDT ---
Created an attachment (id=356)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=356)
This patch should fix the problem.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 04, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2933


Sobirari Muhomori <maxmo@pochta.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |baryluk@smp.if.uj.edu.pl




--- Comment #2 from Sobirari Muhomori <maxmo@pochta.ru>  2009-06-04 01:07:00 PDT ---
*** Issue 3048 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 10, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2933


Sobirari Muhomori <maxmo@pochta.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@metalanguage.com




--- Comment #3 from Sobirari Muhomori <maxmo@pochta.ru>  2009-06-10 02:35:19 PDT ---
*** Issue 2799 has been marked as a duplicate of this issue. ***

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


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #4 from Don <clugdbug@yahoo.com.au> 2010-05-14 12:29:43 PDT ---
On svn 484(DMD 2.046), this patch doesn't fix the test case. It's possible that the patch will work once bug 3667 is fixed, but I haven't tested that.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 05, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2933


Don <clugdbug@yahoo.com.au> changed:

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


--- Comment #5 from Don <clugdbug@yahoo.com.au> 2010-06-05 03:47:28 PDT ---
Fixed when bug 3667 was fixed, in svn 490 (DMD 2.047).

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