summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2015-01-02 19:00:08 +0200
committerZahary Karadjov <zahary@gmail.com>2015-01-02 23:58:24 +0200
commitaa69a8a09f990f485e4ae7058b15067c70e70e28 (patch)
tree7dbe1f4d2f1119f0ccfaaf2e01a0795c2d8a0039
parent5b32fb1791899a86afbb19a0c4e8d0ded0c362eb (diff)
downloadNim-aa69a8a09f990f485e4ae7058b15067c70e70e28.tar.gz
expand the test case for bug 1049
-rw-r--r--compiler/semtypes.nim3
-rw-r--r--tests/metatype/tstaticparams.nim11
2 files changed, 11 insertions, 3 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index eb15c3809..14ab7e6ba 100644
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -225,11 +225,10 @@ proc semArrayIndex(c: PContext, n: PNode): PType =
     elif e.kind == nkSym and e.typ.kind == tyStatic:
       if e.sym.ast != nil:
         return semArrayIndex(c, e.sym.ast)
-      internalAssert c.inGenericContext > 0
       if not isOrdinalType(e.typ.lastSon):
         localError(n[1].info, errOrdinalTypeExpected)
       result = makeRangeWithStaticExpr(c, e)
-      result.flags.incl tfUnresolved
+      if c.inGenericContext >0: result.flags.incl tfUnresolved
     elif e.kind in nkCallKinds and hasGenericArguments(e):
       if not isOrdinalType(e.typ):
         localError(n[1].info, errOrdinalTypeExpected)
diff --git a/tests/metatype/tstaticparams.nim b/tests/metatype/tstaticparams.nim
index b34eaa211..e53e478f0 100644
--- a/tests/metatype/tstaticparams.nim
+++ b/tests/metatype/tstaticparams.nim
@@ -65,7 +65,7 @@ proc matrix_3*[M, N: static[int]; T](mat: Matrix[M,N,T], a: array[N, int]) = dis
 proc matrix_4*[M, N: static[int]; T](mat: Matrix[M,N,T], a: array[N+1, int]) = discard
 
 var
-  tmat: TMatrix[4,4,int]
+  tmat: Matrix[4,4,int]
   ar1: array[4, int]
   ar2: array[5, int]
 
@@ -74,3 +74,12 @@ matrix_2(tmat, ar2)
 matrix_3(tmat, ar1)
 matrix_4(tmat, ar2)
 
+template reject(x): stmt =
+  static: assert(not compiles(x))
+
+# test with arrays of wrong size
+reject matrix_1(tmat, ar2)
+reject matrix_2(tmat, ar1)
+reject matrix_3(tmat, ar2)
+reject matrix_4(tmat, ar1)
+