fix #6637 array index type depends generic (#20673)

(cherry picked from commit aa6f9d490f)
This commit is contained in:
Bung
2022-10-27 18:22:04 +08:00
committed by narimiran
parent 26e52d7c5d
commit cf12d6fcde
2 changed files with 10 additions and 1 deletions

View File

@@ -332,7 +332,7 @@ 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)
if not isOrdinalType(e.typ.lastSon):
if e.typ.lastSon.kind != tyGenericParam and not isOrdinalType(e.typ.lastSon):
let info = if n.safeLen > 1: n[1].info else: n.info
localError(c.config, info, errOrdinalTypeExpected)
result = makeRangeWithStaticExpr(c, e)