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



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




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



19:38:28 EET ---

 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




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




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




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



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




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





 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.
 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





 
 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




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





 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



18:08:34 PST ---

 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






 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



---


 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?
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