Bug 7910 – Compiler gives error when post-contract is used in a function that returns from inside a loop

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-04-14T08:21:00Z
Last change time
2015-07-01T08:43:30Z
Keywords
contracts, rejects-valid
Assigned to
nobody
Creator
thiezz

Comments

Comment #0 by thiezz — 2012-04-14T08:21:46Z
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'.
Comment #1 by alex — 2012-05-02T19:56:34Z
I can confirm; with no contract, DMD emits no error.
Comment #2 by k.hara.pg — 2015-07-01T08:43:30Z
Fortunately fixed in 2.067, by the change: https://github.com/D-Programming-Language/dmd/pull/3979