summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/semtypes.nim4
-rw-r--r--tests/array/tarrindx.nim18
2 files changed, 21 insertions, 1 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index 5172bc653..f14b40a9b 100644
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -288,7 +288,9 @@ proc semArray(c: PContext, n: PNode, prev: PType): PType =
     var indxB = indx
     if indxB.kind in {tyGenericInst, tyAlias, tySink}: indxB = lastSon(indxB)
     if indxB.kind notin {tyGenericParam, tyStatic, tyFromExpr}:
-      if not isOrdinalType(indxB):
+      if indxB.skipTypes({tyRange}).kind in {tyUInt, tyUInt64}:
+        discard
+      elif not isOrdinalType(indxB):
         localError(n.sons[1].info, errOrdinalTypeExpected)
       elif enumHasHoles(indxB):
         localError(n.sons[1].info, errEnumXHasHoles,
diff --git a/tests/array/tarrindx.nim b/tests/array/tarrindx.nim
index a8d72b338..3bb6b0148 100644
--- a/tests/array/tarrindx.nim
+++ b/tests/array/tarrindx.nim
@@ -1,3 +1,8 @@
+discard """
+  output: '''0
+0'''
+"""
+
 # test another strange bug ... (I hate this compiler; it is much too buggy!)
 
 proc putEnv(key, val: string) =
@@ -11,3 +16,16 @@ proc putEnv(key, val: string) =
   env[len(key)] = '='
   for i in 0..len(val)-1:
     env[len(key)+1+i] = val[i]
+
+# bug #7153
+const
+  UnsignedConst = 1024'u
+type
+  SomeObject* = object
+    s1: array[UnsignedConst, uint32]
+
+var
+  obj: SomeObject
+
+echo obj.s1[0]
+echo obj.s1[0u]