Bug 12167 – GIT HEAD: AAs are broken

Status
RESOLVED
Resolution
INVALID
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-14T23:10:00Z
Last change time
2014-03-06T18:01:27Z
Assigned to
nobody
Creator
temtaime

Comments

Comment #0 by temtaime — 2014-02-14T23:10:07Z
immutable int[int] table; static this() { table = [ 1: 2 ]; table.rehash; } src\druntime\import\object.di(382): Error: cannot implicitly convert expression (aa) of type immutable(int[int]) to immutable(int)[int] Error: template instance object.rehash!(immutable(int[int]), immutable(int), int) error instantiating ------------------------------------------------------------- Also it rejects previously valid code: class A {} immutable A[short] table; auto a = table.get(10, null); src\druntime\import\object.di(487): object.get(T : Value[Key], Value, Key, K, V)(T* aa, K key, lazy V defaultValue) if (is(typeof(true ? (*aa)[key] : defaultValue)))
Comment #1 by temtaime — 2014-02-14T23:11:53Z
Another case: immutable short[short] table; auto v = table.get(10, 0); src\druntime\import\object.di(487): object.get(T : Value[Key], Value, Key, K, V)(T* aa, K key, lazy V defaultValue) if (is(typeof(true ? (*aa)[key] : defaultValue)))
Comment #2 by dlang-bugzilla — 2014-02-15T09:38:28Z
(In reply to comment #0) > Also it rejects previously valid code: > class A {} > > immutable A[short] table; > auto a = table.get(10, null); This is the only example that I succeeded to compile with DMD 2.064.2. This example was broken in these pull requests: https://github.com/D-Programming-Language/dmd/pull/2856 https://github.com/D-Programming-Language/druntime/pull/668
Comment #3 by temtaime — 2014-02-15T09:42:14Z
http://dpaste.dzfl.pl/9c0ffd7fcadb All my examples previously worked.
Comment #4 by dlang-bugzilla — 2014-02-15T09:46:50Z
Sorry about that. Didn't look at the code too closely, didn't realize it contained statements that needed to be wrapped in functions.
Comment #5 by temtaime — 2014-02-15T09:57:44Z
Do not sorry :) It's my mistake i had to do it by myself
Comment #6 by yebblies — 2014-02-15T19:53:15Z
That's weird, it looks like the compiler is trying to tail-const the AA, badly.
Comment #7 by k.hara.pg — 2014-02-15T21:23:58Z
This is one another regression caused by removing object.AssociativeArray. struct S11 { int opCmp(T : typeof(this))(T) { return 0; } } void main() { { auto ti = typeid(int[S11]); } } This code compiles used to compile until 2.064, but in 2.065 development term, it has been made disallowed by the fix for issue 11591. But in git head, it does not cause error. I noticed the change during maintain 2.065 branch (Related PR: https://github.com/D-Programming-Language/dmd/pull/3271).
Comment #8 by yebblies — 2014-02-16T06:12:50Z
(In reply to comment #0) > immutable int[int] table; > > static this() { > table = [ 1: 2 ]; > table.rehash; > } > > src\druntime\import\object.di(382): Error: cannot implicitly convert expression > (aa) of type immutable(int[int]) to immutable(int)[int] > > Error: template instance object.rehash!(immutable(int[int]), immutable(int), > int) error instantiating > Wait, wtf, why are you rehashing an immutable AA? That obviously doesn't work, it's immutable. Looks like it was previously accepting invalid code. (In reply to comment #7) > This is one another regression caused by removing object.AssociativeArray. > > struct S11 { int opCmp(T : typeof(this))(T) { return 0; } } > void main() > { > { auto ti = typeid(int[S11]); } > } > > This code compiles used to compile until 2.064, but in 2.065 development term, > it has been made disallowed by the fix for issue 11591. > > But in git head, it does not cause error. I noticed the change during maintain > 2.065 branch (Related PR: > https://github.com/D-Programming-Language/dmd/pull/3271). For me it gives: DMD v2.065 DEBUG testx.d(4): Error: associative array key type S11 does not have 'const int opCmp(ref const S11)' member function With git head.
Comment #9 by yebblies — 2014-02-16T06:44:09Z
(In reply to comment #0) > > Also it rejects previously valid code: > class A {} > > immutable A[short] table; > auto a = table.get(10, null); > > src\druntime\import\object.di(487): object.get(T : Value[Key], Value, > Key, K, V)(T* aa, K key, lazy V defaultValue) if (is(typeof(true ? (*aa)[key] : > defaultValue))) I honestly don't know how to write a constraint for this.
Comment #10 by temtaime — 2014-02-16T07:49:16Z
yebblies, somewhere(maybe on dlang.org) i seen that it's need to rehash any AAs, even aas literals.
Comment #11 by yebblies — 2014-02-16T07:59:41Z
(In reply to comment #10) > yebblies, somewhere(maybe on dlang.org) i seen that it's need to rehash any > AAs, even aas literals. It works on AA literals, just not on const/immutable AAs, because it may modify data inside them. If it previously worked on immutable AAs then that was a bug.
Comment #12 by bugzilla — 2014-02-18T18:08:34Z
(In reply to comment #11) > It works on AA literals, just not on const/immutable AAs, because it may modify > data inside them. If it previously worked on immutable AAs then that was a > bug. Hmm, so this is resolved invalid?
Comment #13 by yebblies — 2014-02-19T02:35:04Z
(In reply to comment #12) > (In reply to comment #11) > > It works on AA literals, just not on const/immutable AAs, because it may modify > > data inside them. If it previously worked on immutable AAs then that was a > > bug. > > Hmm, so this is resolved invalid? This one is valid, I guess. class A {} immutable A[short] table; auto a = table.get(10, null); src\druntime\import\object.di(487): object.get(T : Value[Key], Value, Key, K, V)(T* aa, K key, lazy V defaultValue) if (is(typeof(true ? (*aa)[key] : defaultValue)))
Comment #14 by k.hara.pg — 2014-03-06T18:01:27Z
(In reply to comment #12) > (In reply to comment #11) > > It works on AA literals, just not on const/immutable AAs, because it may modify > > data inside them. If it previously worked on immutable AAs then that was a > > bug. > > Hmm, so this is resolved invalid? The rehash case in comment#0 is invalid so it modifies immutable data. The comment#7 case would not be related to the AA implementation change. See: https://d.puremagic.com/issues/show_bug.cgi?id=12307 And, the 'get' case is properly separated to the bug 12220, and has been properly fixed by the IFTI enhancement issue 12290 in git-head. So I'll mark this issue as resolved-invalid.