diff options
author | Araq <rumpf_a@web.de> | 2013-05-26 01:19:19 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-05-26 01:19:19 +0200 |
commit | ca02dfab4801930ba44d08fc655fcbc6e3b11a21 (patch) | |
tree | 820ac655a54a12c4881cf6def58ebd111d546a6c /compiler | |
parent | da93b591e2b2dd6323c368d4586650711b5c0f3c (diff) | |
download | Nim-ca02dfab4801930ba44d08fc655fcbc6e3b11a21.tar.gz |
implements #397
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semtypes.nim | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 13cf44426..658b3507f 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -182,7 +182,16 @@ proc semArray(c: PContext, n: PNode, prev: PType): PType = if sonsLen(n) == 3: # 3 = length(array indx base) if isRange(n[1]): indx = semRangeAux(c, n[1], nil) - else: indx = semTypeNode(c, n.sons[1], nil) + else: + let e = semExprWithType(c, n.sons[1], {efDetermineType}) + if e.kind in {nkIntLit..nkUInt64Lit}: + indx = newTypeS(tyRange, c) + indx.n = newNodeI(nkRange, n.info) + addSon(indx.n, newIntTypeNode(e.kind, 0, e.typ)) + addSon(indx.n, newIntTypeNode(e.kind, e.intVal-1, e.typ)) + addSonSkipIntLit(indx, e.typ) + else: + indx = e.typ.skipTypes({tyTypeDesc}) addSonSkipIntLit(result, indx) if indx.kind == tyGenericInst: indx = lastSon(indx) if indx.kind != tyGenericParam: |