www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7910] New: Compiler gives error when post-contract is used in a function that returns from inside a loop

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7910

           Summary: Compiler gives error when post-contract is used in a
                    function that returns from inside a loop
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: thiezz gmail.com



When using this code with DMD32 v2.059:

int func()
out(result) { assert(result == 3); }
body
{
  while(true) {
    return 3;
  }
}

void main() {
  func();
}

The compiler produces the following error:
bug.d(1): Error: function bug.func no return exp; or assert(0); at end of
function

The error also happens when a 'for' is used instead of 'while'.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 14 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7910


Alex Rønne Petersen <xtzgzorex gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |contracts
                 CC|                            |xtzgzorex gmail.com



19:56:34 PDT ---
I can confirm; with no contract, DMD emits no error.

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