www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12167] New: GIT HEAD: AAs are broken

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167

           Summary: GIT HEAD: AAs are broken
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: temtaime gmail.com


--- Comment #0 from Temtaime <temtaime gmail.com> 2014-02-14 23:10:07 PST ---
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)))

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167



--- Comment #1 from Temtaime <temtaime gmail.com> 2014-02-14 23:11:53 PST ---
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)))

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 14 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167


Vladimir Panteleev <thecybershadow gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow gmail.com


--- Comment #2 from Vladimir Panteleev <thecybershadow gmail.com> 2014-02-15
19:38:28 EET ---
(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 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 15 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167



--- Comment #3 from Temtaime <temtaime gmail.com> 2014-02-15 09:42:14 PST ---
http://dpaste.dzfl.pl/9c0ffd7fcadb

All my examples previously worked.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 15 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167



--- Comment #4 from Vladimir Panteleev <thecybershadow gmail.com> 2014-02-15
19:46:50 EET ---
Sorry about that. Didn't look at the code too closely, didn't realize it
contained statements that needed to be wrapped in functions.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 15 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167



--- Comment #5 from Temtaime <temtaime gmail.com> 2014-02-15 09:57:44 PST ---
Do not sorry :)
It's my mistake i had to do it by myself

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 15 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com


--- Comment #6 from yebblies <yebblies gmail.com> 2014-02-16 14:53:15 EST ---
That's weird, it looks like the compiler is trying to tail-const the AA, badly.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 15 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167



--- Comment #7 from Kenji Hara <k.hara.pg gmail.com> 2014-02-15 21:23:58 PST ---
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).

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 15 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167



--- Comment #8 from yebblies <yebblies gmail.com> 2014-02-17 01:12:50 EST ---
(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. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 16 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167



--- Comment #9 from yebblies <yebblies gmail.com> 2014-02-17 01:44:09 EST ---
(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. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 16 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167



--- Comment #10 from Temtaime <temtaime gmail.com> 2014-02-16 07:49:16 PST ---
yebblies, somewhere(maybe on dlang.org) i seen that it's need to rehash any
AAs, even aas literals.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 16 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167



--- Comment #11 from yebblies <yebblies gmail.com> 2014-02-17 02:59:41 EST ---
(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. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 16 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com


--- Comment #12 from Walter Bright <bugzilla digitalmars.com> 2014-02-18
18:08:34 PST ---
(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? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 18 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167



--- Comment #13 from yebblies <yebblies gmail.com> 2014-02-19 21:35:04 EST ---
(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))) -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 19 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12167


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #14 from Kenji Hara <k.hara.pg gmail.com> 2014-03-06 18:01:27 PST
---
(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. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 06 2014