diff options
author | Araq <rumpf_a@web.de> | 2015-07-03 10:31:49 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-07-03 10:31:49 +0200 |
commit | 2d196442fa6db010307a2dc62c65f1129ce9705d (patch) | |
tree | 7ded4f000191041149a78fc47cb43e360533666e | |
parent | 6b3abdba0f930bb714644a368a0d23b169c30a8c (diff) | |
download | Nim-2d196442fa6db010307a2dc62c65f1129ce9705d.tar.gz |
fixes #3048, fixes #3047
-rw-r--r-- | compiler/semtypes.nim | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index d0cd70947..b82c51c07 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -251,19 +251,21 @@ proc semArrayIndex(c: PContext, n: PNode): PType = proc semArray(c: PContext, n: PNode, prev: PType): PType = var base: PType - result = newOrPrevType(tyArray, prev, c) if sonsLen(n) == 3: # 3 = length(array indx base) - var indx = semArrayIndex(c, n[1]) - addSonSkipIntLit(result, indx) - if indx.kind == tyGenericInst: indx = lastSon(indx) - if indx.kind notin {tyGenericParam, tyStatic, tyFromExpr}: - if not isOrdinalType(indx): + let indx = semArrayIndex(c, n[1]) + var indxB = indx + if indxB.kind == tyGenericInst: indxB = lastSon(indxB) + if indxB.kind notin {tyGenericParam, tyStatic, tyFromExpr}: + if not isOrdinalType(indxB): localError(n.sons[1].info, errOrdinalTypeExpected) - elif enumHasHoles(indx): + elif enumHasHoles(indxB): localError(n.sons[1].info, errEnumXHasHoles, - typeToString(indx.skipTypes({tyRange}))) + typeToString(indxB.skipTypes({tyRange}))) 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) else: localError(n.info, errArrayExpectsTwoTypeParams) |