D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4429 - .keys for V[real] broken
Summary: .keys for V[real] broken
Status: RESOLVED DUPLICATE of issue 4201
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-05 07:53 UTC by David Simcha
Modified: 2010-07-06 04:38 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2010-07-05 07:53:57 UTC
This bug seems to apply no matter what V is, but only applies when the key is a real, not a float or a double.

import std.stdio;

void main() {
    uint[real] foo;
    foo[3.14159265] = 1;
    foo[2.71828182] = 2;
    foo[6.66] = 3;

    writeln(foo);  // Works
    writeln(foo.keys);  // 6.66 -0 -0
}
Comment 1 bearophile_hugs 2010-07-05 09:38:57 UTC
Bugs happen, it's life. But this is silly. Phobos/druntime must be designed differently, with a more serious amount of unittests: a bug as simple as this one must be found during development of Phobos/druntime, and not by language users because the code is written in an amateurish way.
Comment 2 Steven Schveighoffer 2010-07-06 04:38:40 UTC
I think the keys member is horribly broken if the size of the key isn't size_t.  I'll add an appropriate comment to 4201 to indicate reals also are a problem.

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