parent
6b3abdba0f
commit
2d196442fa
1 changed files with 10 additions and 8 deletions
|
|
@ -251,19 +251,21 @@ proc semArrayIndex(c: PContext, n: PNode): PType =
|
||||||
|
|
||||||
proc semArray(c: PContext, n: PNode, prev: PType): PType =
|
proc semArray(c: PContext, n: PNode, prev: PType): PType =
|
||||||
var base: PType
|
var base: PType
|
||||||
result = newOrPrevType(tyArray, prev, c)
|
|
||||||
if sonsLen(n) == 3:
|
if sonsLen(n) == 3:
|
||||||
# 3 = length(array indx base)
|
# 3 = length(array indx base)
|
||||||
var indx = semArrayIndex(c, n[1])
|
let indx = semArrayIndex(c, n[1])
|
||||||
addSonSkipIntLit(result, indx)
|
var indxB = indx
|
||||||
if indx.kind == tyGenericInst: indx = lastSon(indx)
|
if indxB.kind == tyGenericInst: indxB = lastSon(indxB)
|
||||||
if indx.kind notin {tyGenericParam, tyStatic, tyFromExpr}:
|
if indxB.kind notin {tyGenericParam, tyStatic, tyFromExpr}:
|
||||||
if not isOrdinalType(indx):
|
if not isOrdinalType(indxB):
|
||||||
localError(n.sons[1].info, errOrdinalTypeExpected)
|
localError(n.sons[1].info, errOrdinalTypeExpected)
|
||||||
elif enumHasHoles(indx):
|
elif enumHasHoles(indxB):
|
||||||
localError(n.sons[1].info, errEnumXHasHoles,
|
localError(n.sons[1].info, errEnumXHasHoles,
|
||||||
typeToString(indx.skipTypes({tyRange})))
|
typeToString(indxB.skipTypes({tyRange})))
|
||||||
base = semTypeNode(c, n.sons[2], nil)
|
base = semTypeNode(c, n.sons[2], nil)
|
||||||
|
# ensure we only construct a tyArray when there was no error (bug #3048):
|
||||||
|
result = newOrPrevType(tyArray, prev, c)
|
||||||
|
addSonSkipIntLit(result, indx)
|
||||||
addSonSkipIntLit(result, base)
|
addSonSkipIntLit(result, base)
|
||||||
else:
|
else:
|
||||||
localError(n.info, errArrayExpectsTwoTypeParams)
|
localError(n.info, errArrayExpectsTwoTypeParams)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue