D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 856 - foreach doesn't work when accessing elements as supertypes
Summary: foreach doesn't work when accessing elements as supertypes
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL: http://dstress.kuehne.cn/run/c/cast_2...
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2007-01-19 02:01 UTC by Brad Roberts
Modified: 2014-02-15 13:12 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Brad Roberts 2007-01-19 02:01:09 UTC
module dstress.run.c.cast_29_B;

class Foo{
}

class Bar : Foo{
}

int main(){
	Bar[] bars=new Bar[100];

	foreach(Foo f; bars){
		return 0;
	}

	assert(0);
}

$ dmd cast_29_B.d
cast_29_B.d(12): Error: foreach: Bar[] is not an array of dstress.run.c.cast_29_B.Foo
Comment 1 Alexey Ivanov 2010-01-15 17:02:56 UTC
Works in dmd 1.055 and dmd 2.039