fix #20248;fix #6215;turns into simple CT error (#21141)

This commit is contained in:
Bung 2022-12-21 03:23:48 +08:00 • committed by GitHub
commit 40b5c4c4c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -328,6 +328,8 @@ proc semRange(c: PContext, n: PNode, prev: PType): PType =
proc semArrayIndex(c: PContext, n: PNode): PType = proc semArrayIndex(c: PContext, n: PNode): PType =
if isRange(n): if isRange(n):
result = semRangeAux(c, n, nil) result = semRangeAux(c, n, nil)
elif n.kind == nkInfix and n[0].kind == nkIdent and n[0].ident.s == "..<":
result = errorType(c)
else: else:
let e = semExprWithType(c, n, {efDetermineType}) let e = semExprWithType(c, n, {efDetermineType})
if e.typ.kind == tyFromExpr: if e.typ.kind == tyFromExpr:

14
tests/array/t20248.nim Normal file
View file

@ -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]