Bug 3824 – An AA with an AA as key doesn't seem to work

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-02-18T11:26:00Z
Last change time
2015-06-09T01:27:38Z
Keywords
wrong-code
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2010-02-18T11:26:09Z
import std.stdio; void main() { int[int] aa1 = [1:2, 3:4]; int[int] aa2 = [5:6, 7:8]; byte[int[int]] s; s[aa1] = 1; s[aa2] = 2; writeln(s); } It prints: [[1:2,3:4]:2] Instead of something as: [[1: 2, 3: 4]: 1, [5: 6, 7: 8]: 2]
Comment #1 by bearophile_hugs — 2012-10-21T13:47:18Z
It doesn't work still, see: void main() { int[int] aa1 = [1: 2]; int[int] aa2 = [1: 2]; int[int[int]] aa3; aa3[aa1] = 1; aa3[aa2] = 2; assert(aa3.length == 1); } In DMD 2.061alpha the aa3 has two identical keys.
Comment #2 by andrej.mitrovich — 2012-10-21T13:54:26Z
(In reply to comment #1) > It doesn't work still, see: > > void main() { > int[int] aa1 = [1: 2]; > int[int] aa2 = [1: 2]; > int[int[int]] aa3; > aa3[aa1] = 1; > aa3[aa2] = 2; > assert(aa3.length == 1); > } > > > In DMD 2.061alpha the aa3 has two identical keys. Have you tried HEAD? I see two keys: assert(aa3.length == 2); // passes for me
Comment #3 by andrej.mitrovich — 2012-10-21T13:57:54Z
(In reply to comment #2) > (In reply to comment #1) > > It doesn't work still, see: > > > > void main() { > > int[int] aa1 = [1: 2]; > > int[int] aa2 = [1: 2]; > > int[int[int]] aa3; > > aa3[aa1] = 1; > > aa3[aa2] = 2; > > assert(aa3.length == 1); > > } > > > > > > In DMD 2.061alpha the aa3 has two identical keys. > > Have you tried HEAD? I see two keys: > assert(aa3.length == 2); // passes for me On second thought I'm not sure what you're asking. You want the two keys to be just one key?
Comment #4 by bearophile_hugs — 2012-10-21T14:15:58Z
(In reply to comment #3) > On second thought I'm not sure what you're asking. You want the two keys to be > just one key? Yeah, sorry for not being clear enough. aa1 == aa2 so at the end aa3 should contain only one key with value 2.
Comment #5 by clugdbug — 2013-01-28T00:40:02Z
(In reply to comment #1) > It doesn't work still, see: > > void main() { > int[int] aa1 = [1: 2]; > int[int] aa2 = [1: 2]; > int[int[int]] aa3; > aa3[aa1] = 1; > aa3[aa2] = 2; > assert(aa3.length == 1); > } > > > In DMD 2.061alpha the aa3 has two identical keys. This code passes now on git head (f8ddb72).
Comment #6 by bearophile_hugs — 2013-01-28T03:01:26Z
Seems fixed. Closed.