D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3058 - [CTFE] Cannot return out of foreach range statement
Summary: [CTFE] Cannot return out of foreach range statement
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 All
: P2 normal
Assignee: Walter Bright
URL:
Keywords: patch, wrong-code
Depends on: 1972
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-07 17:43 UTC by Shin Fujishiro
Modified: 2015-06-09 01:27 UTC (History)
0 users

See Also:


Attachments
Fix the problem (DMD 2.030) (567 bytes, patch)
2009-06-07 17:43 UTC, Shin Fujishiro
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Shin Fujishiro 2009-06-07 17:43:33 UTC
Created attachment 396 [details]
Fix the problem (DMD 2.030)

Return statement is not handled in ForeachRangeStatement::interpret(). As a result, the static assert in this code wrongly fails:
--------------------
int foo()
{
    foreach (i; 0 .. 1)
        return 1;
    return 0;
}
static assert(foo() == 1);
--------------------
Comment 1 Walter Bright 2009-09-03 13:38:48 UTC
Fixed dmd 2.032