Jump to page: 1 2
Thread overview
[Issue 12167] New: GIT HEAD: AAs are broken
Feb 15, 2014
Temtaime
Feb 15, 2014
Temtaime
Feb 15, 2014
Vladimir Panteleev
Feb 15, 2014
Temtaime
Feb 15, 2014
Vladimir Panteleev
Feb 15, 2014
Temtaime
Feb 16, 2014
yebblies
Feb 16, 2014
Kenji Hara
Feb 16, 2014
yebblies
Feb 16, 2014
yebblies
Feb 16, 2014
Temtaime
Feb 16, 2014
yebblies
Feb 19, 2014
Walter Bright
Feb 19, 2014
yebblies
Mar 07, 2014
Kenji Hara
February 15, 2014
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: -------
February 15, 2014
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: -------
February 15, 2014
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: -------
February 15, 2014
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: -------
February 15, 2014
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: -------
February 15, 2014
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: -------
February 16, 2014
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: -------
February 16, 2014
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: -------
February 16, 2014
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: -------
February 16, 2014
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: -------
« First   ‹ Prev
1 2