[Issue 7449] Algebraic's operator[] is incorrect

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 5 20:27:45 PST 2012


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



--- Comment #1 from Andrei Alexandrescu <andrei at metalanguage.com> 2012-02-05 20:27:44 PST ---
Hans Fugal identified this blames to revision 3a1f9109, this snippet:
@@ -313,20 +364,23 @@ private:

         case OpID.index:
             auto me = cast(A*) pStore;
-            static if (isArray!(A))
+            // Added allowed!(...) prompted by a bug report by Chris
+            // Nicholson-Sauls.
+            static if (isArray!(A) && allowed!(typeof(A.init[0])))
             {
                 // array type; input and output are the same VariantN 
                 auto result = cast(VariantN*) parm;
                 size_t index = result.convertsTo!(int)
                     ? result.get!(int) : result.get!(size_t);
                 *result = (*me)[index];
-               break;
+                break;
             }
-            else static if (isAssociativeArray!(A))
+            else static if (isAssociativeArray!(A)
+                    && allowed!(typeof(A.init.values[0])))
             {
                 auto result = cast(VariantN*) parm;
                 *result = (*me)[result.get!(typeof(A.keys[0]))];
-               break;
+                break;
             }
             else
             {

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