D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4337 - Associative array assignment with dstring keys breaks lookup
Summary: Associative array assignment with dstring keys breaks lookup
Status: RESOLVED DUPLICATE of issue 7512
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2010-06-16 23:34 UTC by Justin Spahr-Summers
Modified: 2012-03-23 04:40 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Justin Spahr-Summers 2010-06-16 23:34:22 UTC
void main () {
	int[dstring] foo;
	
	foo = [
		"hello"d : 5
	];
	
	assert("hello"d in foo);
}

This assertion fails on dmd 2.047 on OS X. Using foo["hello"d] = 5; or changing the key type to string works.
Comment 1 Justin Spahr-Summers 2010-06-16 23:36:37 UTC
(In reply to comment #0)
> void main () {
>     int[dstring] foo;
> 
>     foo = [
>         "hello"d : 5
>     ];
> 
>     assert("hello"d in foo);
> }
> 
> This assertion fails on dmd 2.047 on OS X. Using foo["hello"d] = 5; or changing
> the key type to string works.

Forgot to add that the keys and values are still iterable with foreach() - it's just lookup by hash (index or "in" syntax) that fails.
Comment 2 Masahiro Nakagawa 2010-11-06 13:35:24 UTC
I hit this bug when I wrote a Japanese language morphological analysis library (http://bitbucket.org/repeatedly/scrap/src/tip/tinysegmenter.d).

I voted.
Comment 3 Brad Roberts 2011-02-06 15:40:34 UTC
Mass migration of bugs marked as x86-64 to just x86.  The platform run on isn't what's relevant, it's if the app is a 32 or 64 bit app.
Comment 4 yebblies 2012-02-02 23:48:21 UTC
Most likely a druntime string comparison issue.
Comment 5 hsteoh 2012-03-13 22:40:40 UTC
This bug appears to be the same as bug 7512, which has been fixed in git. Please verify.
Comment 6 yebblies 2012-03-23 04:40:54 UTC

*** This issue has been marked as a duplicate of issue 7512 ***