Bug 14182 – AA with pointer key can't find key (regression)

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2015-02-15T09:39:00Z
Last change time
2015-02-19T01:52:04Z
Assigned to
nobody
Creator
timothee.cour2

Comments

Comment #0 by timothee.cour2 — 2015-02-15T09:39:21Z
git head (v2.067-devel-e542e14): dmd -run main.d passes but this is surprising. dmd(2.066.rc2): this fails at pa !in map which seems more correct, but still weird for lines 4 and 5 simultaneously. void main(){ int[int*]map;//Same below if this line changes to int[const(int)*] map; assert(typeof(map).stringof=="int[const(int)*]");//why? assert(is(typeof(map)==int[const(int)*]));//where did const came from assert(is(typeof(map)==int[int*]));//why both are true? auto pa=new int; map[pa]=0; assert(pa !in map);//REGRESSION: worked in dmd.066(rc2) assert((cast(const(int)*)pa) !in map);//why not either? } Furthermore, with int[int*]map=>int[immutable(int)*]map we have: void main(){ int[immutable(int)*]map; assert(is(typeof(map)==int[immutable(int)*]));//ok immutable pa=new int; map[pa]=0; assert(pa !in map);//REGRESSION: worked in dmd.066(rc2) }
Comment #1 by timothee.cour2 — 2015-02-15T09:42:01Z
when I wrote '//REGRESSION: worked in dmd.066(rc2)' it means that the assert passes wrongly but that it correctly failed in dmd.066(rc2), ie that the key was in the map.
Comment #2 by safety0ff.bugz — 2015-02-15T19:21:14Z
Pretty sure this is a duplicate of #14104. I changed all the assertions from "!in" to "in" and it works for me with git master.
Comment #3 by code — 2015-02-19T00:50:44Z
(In reply to Timothee Cour from comment #1) > when I wrote '//REGRESSION: worked in dmd.066(rc2)' it means that the assert > passes wrongly but that it correctly failed in dmd.066(rc2), ie that the key > was in the map. How about you not not not negate so much ;). At best you submit reduced test-cases that can be used as regression test, i.e. fails/asserts for broken compilers, passes for working ones. Indeed it's a dubplicate. One of those actually creates a link @safety0ff.bugz. bug 14104 issue 14104 https://www.bugzilla.org/docs/2.18/html/hintsandtips.html#AEN2328 *** This issue has been marked as a duplicate of issue 14104 ***
Comment #4 by timothee.cour2 — 2015-02-19T01:52:04Z
there's 1 more thing in the bug report: why both are true? assert(is(typeof(map)==int[const(int)*])); assert(is(typeof(map)==int[int*])); furthermore shouldn't we disallow this: int[int*]map; and spit out a compiler error (or deprecation for now) saying that the type should be: int[const(int)*]map;