[Issue 10880] foreach on matrix literal refuses immutable iteration
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 20 14:25:56 PST 2013
https://d.puremagic.com/issues/show_bug.cgi?id=10880
monkeyworks12 at hotmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |monkeyworks12 at hotmail.com
--- Comment #3 from monkeyworks12 at hotmail.com 2013-11-20 14:25:52 PST ---
(In reply to comment #1)
> And nor should it. As the error says, [[1]] has type int[][], and you can't
> implicitly convert int[] to immutable(int[]).
>
> Asking for initializer-style type inference is an enhancement, and doesn't work
> particularly well with the way foreach expands to for.
>
> Alternatives are to use const, or give the aggregate expression an explicit
> type.
In this case, isn't [[1]] a unique expression, so it can be implicitly cast to
immutable? Also, foreach (const v; [[1]]) works, but this doesn't (and it
probably should):
class Test
{
}
foreach (const v; [new Test()])
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list