Bug 7450 – AA: Cannot uniquely infer foreach argument types

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-06T01:45:00Z
Last change time
2012-04-19T15:44:22Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2012-02-06T01:45:43Z
void main() { string[string] hash; hash["foo"] = ""; foreach (name; hash.byKey()) { assert(typeid(string) == typeid(name)); // ok } // Error: cannot uniquely infer foreach argument types foreach (string name; hash.byKey()) { } } I'm confused, why can't I specify the type? It ends up being a string if I don't set it..
Comment #1 by lovelydear — 2012-04-19T15:26:11Z
This compiles and runs with 2.059.
Comment #2 by andrej.mitrovich — 2012-04-19T15:44:22Z
Hmm.. I can't recreate this in 2.057 either. It does crash DMD 2.053 though, so it might have been some kind of lurking bug somewhere.. I'll close it now though.