[Issue 10424] array operations accept rvalues on the lhs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 20 08:33:19 PDT 2013


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


Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich at gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-06-20 08:33:18 PDT ---
In Expression *AssignExp::semantic(Scope *sc) I could add this check:

diff --git a/src/expression.c b/src/expression.c
index becbcbb..19e008d 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -11153,8 +11153,10 @@ Ltupleassign:
     else if (e1->op == TOKslice)
     {
         Type *tn = e1->type->nextOf();
-        if (op == TOKassign && e1->checkModifiable(sc) == 1 &&
!tn->isMutable())
-        {   error("slice %s is not mutable", e1->toChars());
+        if (op == TOKassign && e1->checkModifiable(sc) == 1 &&
+            (!tn->isMutable() || !((SliceExp *)e1)->e1->isLvalue()))
+        {
+            error("slice %s is not mutable", e1->toChars());
             return new ErrorExp();
         }
     }

But I don't think that's totally correct. Kenji?

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