summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBung <crc32@qq.com>2022-12-21 03:23:48 +0800
committerGitHub <noreply@github.com>2022-12-20 20:23:48 +0100
commit40b5c4c4c340d44ee724183306716286e40002cb (patch)
treef33817f98c0f17b0468d456406c6896e46c30085
parent886572a5162beea672d696fb03422e7777f56cfb (diff)
downloadNim-40b5c4c4c340d44ee724183306716286e40002cb.tar.gz
fix #20248;fix #6215;turns into simple CT error (#21141)
-rw-r--r--compiler/semtypes.nim2
-rw-r--r--tests/array/t20248.nim14
2 files changed, 16 insertions, 0 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index dca0d753b..534861e97 100644
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -328,6 +328,8 @@ proc semRange(c: PContext, n: PNode, prev: PType): PType =
 proc semArrayIndex(c: PContext, n: PNode): PType =
   if isRange(n):
     result = semRangeAux(c, n, nil)
+  elif n.kind == nkInfix and n[0].kind == nkIdent and n[0].ident.s == "..<":
+    result = errorType(c)
   else:
     let e = semExprWithType(c, n, {efDetermineType})
     if e.typ.kind == tyFromExpr:
diff --git a/tests/array/t20248.nim b/tests/array/t20248.nim
new file mode 100644
index 000000000..66142548b
--- /dev/null
+++ b/tests/array/t20248.nim
@@ -0,0 +1,14 @@
+discard """
+cmd: "nim check --hints:off $file"
+errormsg: "ordinal type expected; given: Error Type"
+nimout: '''
+t20248.nim(10, 36) Error: ordinal type expected; given: Error Type
+t20248.nim(14, 20) Error: ordinal type expected; given: Error Type
+'''
+"""
+
+type Vec[N: static[int]] = array[0 ..< N, float]
+
+var v: Vec[32]
+
+var stuff: array[0 ..< 16, int]