www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4460] New: (2.047) Internal error when compiling foreach over associative array literal

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

           Summary: (2.047) Internal error when compiling foreach over
                    associative array literal
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: epi atari8.info


--- Comment #0 from Adrian Matoga <epi atari8.info> 2010-07-14 12:11:41 PDT ---
import std.stdio;

void main()
{
    foreach (s, i; [ "a":1, "b":2 ])
    {
        writeln(s, i);
    }
}

The above does not compile. DMD 2.047 gives up with message "Internal error:
e2ir.c 4616".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4460



--- Comment #2 from Don <clugdbug yahoo.com.au> 2010-09-29 00:24:30 PDT ---
The regression was introduced in svn 218, static arrays as values. 
The relevant change was in statement.c, ForeachStatement::semantic.
---
    case Taarray:
        if (!checkForArgTypes())
        return this;

        taa = (TypeAArray *)tab;
        if (dim < 1 || dim > 2)
        {
        error("only one or two arguments for associative array foreach");
        break;
        }
-#if 0
+#if 1
        /* This currently fails if Key or Value is a static array.
         * The fix is to make static arrays a value type, not the
         * kludge they currently are.
         */
        tab = taa->impl->type;
        goto Lagain;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 29 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4460


Don <clugdbug yahoo.com.au> changed:

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


--- Comment #3 from Don <clugdbug yahoo.com.au> 2010-11-22 01:57:10 PST ---
*** Issue 4990 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 22 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4460


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|x86_64                      |x86


--- Comment #4 from Brad Roberts <braddr puremagic.com> 2011-02-06 15:39:52 PST
---
Mass migration of bugs marked as x86-64 to just x86.  The platform run on isn't
what's relevant, it's if the app is a 32 or 64 bit app.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 06 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4460


Andriy <andrden gmail.com> changed:

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


--- Comment #5 from Andriy <andrden gmail.com> 2011-04-19 07:56:24 PDT ---
2.052 the following still doesn't compile: Internal error: e2ir.c 4835

void main(){
    auto a = ["k":"v"].keys;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 19 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4460


Iain Buclaw <ibuclaw ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |ibuclaw ubuntu.com


--- Comment #6 from Iain Buclaw <ibuclaw ubuntu.com> 2011-04-23 12:39:40 PDT ---
Patch:

diff --git a/src/mtype.c b/src/mtype.c
index f8ad06e..1d1fcd6 100644
--- a/src/mtype.c
+++ b/src/mtype.c
   -4173,6 +4173,17    Expression *TypeAArray::dotExp(Scope *sc, Expression *e,
Identifier *ident)
     else
 #endif
     {
+        /* Create a new temporary variable for literal arrays.
+         */
+        if (e->op == TOKassocarrayliteral)
+        {
+            Identifier *idtmp = Lexer::uniqueId("__aatmp");
+            VarDeclaration *aatmp = new VarDeclaration(loc, e->type, idtmp,
new ExpInitializer(0, e));
+            aatmp->storage_class |= STCctfe;
+            Expression *ae = new DeclarationExp(loc, aatmp);
+            e = new CommaExp(loc, ae, new VarExp(loc, aatmp));
+            e = e->semantic(sc);
+        }
         e->type = getImpl()->type;
         e = e->type->dotExp(sc, e, ident);
         //e = Type::dotExp(sc, e, ident);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 23 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4460


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com


--- Comment #7 from Don <clugdbug yahoo.com.au> 2011-04-28 08:41:30 PDT ---
*** Issue 5590 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 28 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4460



--- Comment #8 from Iain Buclaw <ibuclaw ubuntu.com> 2011-04-28 13:49:27 PDT ---
You know I never actually checked to see if this patch worked in DMD...


... it doesn't work DMD. Now why would that be? Seems to because of a similar
reason to issue5683 - backend is simply not getting the passing of the value
right.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 28 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4460


yebblies <yebblies gmail.com> changed:

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


--- Comment #9 from yebblies <yebblies gmail.com> 2011-07-10 15:04:57 EST ---
https://github.com/D-Programming-Language/dmd/pull/221

This also re-enables the check that the index is not ref, and a couple of
others.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 09 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4460


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


--- Comment #10 from Walter Bright <bugzilla digitalmars.com> 2011-08-02
12:14:41 PDT ---
https://github.com/D-Programming-Language/dmd/commit/dd2cf0493ef3e80e36b3f5206b2eac86d337c58b

https://github.com/D-Programming-Language/dmd/commit/c09e14ed2a010b38562a416537ba84871bccc577

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 02 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4460


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dawg dawgfoto.de


--- Comment #11 from Don <clugdbug yahoo.com.au> 2012-04-11 01:01:07 PDT ---
*** Issue 5675 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 11 2012