[Issue 4826] Regression(2.041) "cannot create associative array" and compiler crash

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 8 03:57:26 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4826


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
            Summary|"cannot create associative  |Regression(2.041) "cannot
                   |array" and compiler crash   |create associative array"
                   |                            |and compiler crash
           Severity|normal                      |regression


--- Comment #6 from Don <clugdbug at yahoo.com.au> 2010-09-08 03:56:59 PDT ---
The original test case, and the one in comment 4, have slightly different
causes. In comment 4, the problem is that AssociativeArray!() needs a scope, so
that it can be instantiated. This is fixed by in the template.c patch. I
believe that 'sc' is a correct scope, but I'm not certain.

The original test case is fixed by the patch to mtype.c. It's just error
suppression.

Finally, I have a third test case which didn't even work on 2.040. This
compiles when both patches are in place.
====================
void bug4826c(T)(int[int] value, T x) {}

void test4826c()
{
   AssociativeArray!(int, int) z;
   bug4826c(z,1);
}

====================

// Type::deduceType(), template.c line 1920
    if (ty != tparam->ty)
+    {
+        // Can't instantiate AssociativeArray!() without a scope
+        if (tparam->ty == Taarray && !((TypeAArray*)tparam)->sc)
+            ((TypeAArray*)tparam)->sc = sc;
        return implicitConvTo(tparam);
+    }
//      goto Lnomatch;

    if (nextOf())
        return nextOf()->deduceType(sc, tparam->nextOf(), parameters,
dedtypes);

Lexact:
    return MATCHexact;

--------------
Also: mtype.c, line 7000.

MATCH TypeStruct::implicitConvTo(Type *to)
{   MATCH m;

    //printf("TypeStruct::implicitConvTo(%s => %s)\n", toChars(),
to->toChars());
    if (to->ty == Taarray)
+    {
+        // If there is an error instantiating AssociativeArray!(), it
shouldn't
+        // be reported -- it just means implicit conversion is impossible.
+        ++global.gag;
+        int errs = global.errors;
        to = ((TypeAArray*)to)->getImpl()->type;
+        --global.gag;
+        if (errs != global.errors)
+        {   global.errors = errs;
+            return MATCHnomatch;
+        }
+    }

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


More information about the Digitalmars-d-bugs mailing list