digitalmars.D.bugs - [Issue 4564] New: ICE on undefined variable in foreach over 0 .. undef
- d-bugmail puremagic.com (32/32) Aug 01 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4564
- d-bugmail puremagic.com (49/49) Aug 10 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4564
- d-bugmail puremagic.com (10/10) Aug 11 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4564
- d-bugmail puremagic.com (12/12) Aug 27 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4564
http://d.puremagic.com/issues/show_bug.cgi?id=4564
Summary: ICE on undefined variable in foreach over 0 .. undef
Product: D
Version: D2
Platform: Other
OS/Version: All
Status: NEW
Keywords: ice-on-invalid-code
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: braddr puremagic.com
---
module test;
int main()
{
foreach(i; 0 .. undef) {}
return 0;
}
foreach.d(4): Error: undefined identifier undef
dmd: statement.c:2242: virtual int ForeachRangeStatement::blockExit():
Assertion `0' failed.
The code:
int ForeachRangeStatement::blockExit()
{
assert(0);
... more code, but not reachable
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 01 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4564
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
CC| |clugdbug yahoo.com.au
When an error occurs in ForeachRangeStatement::semantic, it returns this.
That's a problem because foreachrangestatement doesn't support blockExit;
foreachrange MUST be turned into a for statement during the semantic pass.
I found a few variations of this error.
Now that we have a working _error type, it seems perfectly fine to just let it
through: the test suite passes. This also has the advantage that errors in the
foreach body are reported.
PATCH:
Statement *ForeachRangeStatement::semantic, line 2130.
/* Must infer types from lwr and upr
*/
Type *tlwr = lwr->type->toBasetype();
if (tlwr->ty == Tstruct || tlwr->ty == Tclass)
{
/* Just picking the first really isn't good enough.
*/
arg->type = lwr->type->mutableOf();
}
else
{
AddExp ea(loc, lwr, upr);
Expression *e = ea.typeCombine(sc);
- if (e->op == TOKerror)
- return this;
arg->type = ea.type->mutableOf();
lwr = ea.e1;
upr = ea.e2;
}
EXTENDED TEST CASE
struct Bug4564{}
void bug4564()
{
foreach(i; 3.1 ..Bug4564()) {
foreach(j; 2.1..Bug4564()) {}
}
foreach(i; 0..undef){
thisShouldGenerateAnError();
}
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 10 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4564
Brad Roberts <braddr puremagic.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kulhanek.5 wright.edu
---
*** Issue 4626 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: -------
Aug 11 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4564
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |bugzilla digitalmars.com
Resolution| |FIXED
21:36:47 PDT ---
http://www.dsource.org/projects/dmd/changeset/636
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 27 2010









d-bugmail puremagic.com 