D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7450 - AA: Cannot uniquely infer foreach argument types
Summary: AA: Cannot uniquely infer foreach argument types
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-06 01:45 UTC by Andrej Mitrovic
Modified: 2012-04-19 15:44 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 Andrej Mitrovic 2012-02-06 01:45:43 UTC
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 SomeDude 2012-04-19 15:26:11 UTC
This compiles and runs with 2.059.
Comment 2 Andrej Mitrovic 2012-04-19 15:44:22 UTC
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.