February 22, 2013 [Issue 9570] New: Wrong foreach index implicit conversion error | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=9570 Summary: Wrong foreach index implicit conversion error Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: diagnostic, rejects-valid Severity: minor Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2013-02-22 09:38:53 PST --- void main() { ubyte[256] data; foreach (const i, x; data) data[i] = i; } DMD 2.063alpha gives: test.d(4): Error: cannot implicitly convert expression (i) of type const(uint) to ubyte Here "data" is a fixed-size array, with length known statically to be 256, so the index "i" of the foreach is statically known to be in [0,256[, that is the range of a ubyte. So the conversion error given by the compiler is wrong. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation