summary refs log tree commit diff stats
path: root/compiler/semexprs.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-08-26 17:29:56 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-08-26 17:29:56 +0200
commitb4d7ab3caab6b4e1b00d29071ebee7f0372f3512 (patch)
treefc4b7ce439b57957aefb8a66952d6ea4fa5ff5e3 /compiler/semexprs.nim
parent2b0e9aa16701e83c1f54f029cf44f5717740dbfa (diff)
downloadNim-b4d7ab3caab6b4e1b00d29071ebee7f0372f3512.tar.gz
fixes #4179; disallow assignments to openarrays
Diffstat (limited to 'compiler/semexprs.nim')
-rw-r--r--compiler/semexprs.nim5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 16dc159bd..274bb15b9 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -1400,8 +1400,9 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
   # a = b # both are vars, means: a[] = b[]
   # a = b # b no 'var T' means: a = addr(b)
   var le = a.typ
-  if skipTypes(le, {tyGenericInst}).kind != tyVar and
-      isAssignable(c, a) == arNone:
+  if (skipTypes(le, {tyGenericInst}).kind != tyVar and
+        isAssignable(c, a) == arNone) or
+      skipTypes(le, abstractVar).kind in {tyOpenArray, tyVarargs}:
     # Direct assignment to a discriminant is allowed!
     localError(a.info, errXCannotBeAssignedTo,
                renderTree(a, {renderNoComments}))