If you add #pragma strict_types to the file and still get that behaviour, it would be a bug. If you don't (add the line), you can only be sure your program is less future safe than it would be with a correct type there.
/ Johan Sundström (Achtung Liebe!)
Previous text:
2004-06-06 19:37: Subject: Data types in foreach
Hi there,
Just found that following construct:
mapping m = ([ "key": "value" ]); array a = ({ m });
foreach (a; ; int v) // Note the type of v write("%O", v); ...does work (7.6.6) - it prints mapping, while typeof(v) is int (_typeof(v) is mapping, however).
Actually, it doesn't matter which type is used to declare v - it will work anyway - both for indexes and values:
foreach (anyvalue; int k; int v) // This will always work, regardless write("%O=%O\n", k, v); // of type of anyvalue and it's elements
Seems to be a bug or?
Regards, /Al
/ Brevbäraren