implements #397
This commit is contained in:
parent
da93b591e2
commit
ca02dfab48
2 changed files with 13 additions and 1 deletions
|
|
@ -182,7 +182,16 @@ proc semArray(c: PContext, n: PNode, prev: PType): PType =
|
||||||
if sonsLen(n) == 3:
|
if sonsLen(n) == 3:
|
||||||
# 3 = length(array indx base)
|
# 3 = length(array indx base)
|
||||||
if isRange(n[1]): indx = semRangeAux(c, n[1], nil)
|
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)
|
addSonSkipIntLit(result, indx)
|
||||||
if indx.kind == tyGenericInst: indx = lastSon(indx)
|
if indx.kind == tyGenericInst: indx = lastSon(indx)
|
||||||
if indx.kind != tyGenericParam:
|
if indx.kind != tyGenericParam:
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@ Compiler Additions
|
||||||
Language Additions
|
Language Additions
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
- Arrays can now be declared with a single integer literal ``N`` instead of a
|
||||||
|
range; the range is then ``0..N-1``.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2013-05-20 New website design!
|
2013-05-20 New website design!
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue