From b4d7ab3caab6b4e1b00d29071ebee7f0372f3512 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Fri, 26 Aug 2016 17:29:56 +0200 Subject: [PATCH] fixes #4179; disallow assignments to openarrays --- compiler/semexprs.nim | 5 +++-- 1 file 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}))