D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6811 - Confusion between string* and immutable(char)*, related to AA's
Summary: Confusion between string* and immutable(char)*, related to AA's
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-10-13 09:43 UTC by David Simcha
Modified: 2011-10-13 09:49 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2011-10-13 09:43:59 UTC
void doExclude(string exclude) {
    string[string] aa;

    int[] keep;
    foreach(int i, h; ["a", "b"]) {
        auto ptr = h in aa;
        pragma(msg, typeof(ptr));  // string*
        pragma(msg, typeof(*ptr)); // string
        if(*h != exclude) keep ~= i;
    }
}

test.d(9): Error: incompatible types for ((*cast(immutable(char)*)h) != (exclude)): 'immutable(char)' and 'string'
Comment 1 David Simcha 2011-10-13 09:49:30 UTC
(Slaps self in forehead.)  Never mind, I see what I did now.  I used *h where I meant *ptr and forgot that strings implicitly convert to char*.