make unary minus part of number literals, refs #17020 (#17488)

* make unary minus part of number literals, refs #17020
* fixes regression
This commit is contained in:
Andreas Rumpf 2021-03-24 09:47:11 +01:00 • committed by GitHub
commit 86af2f7b50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 173 additions and 39 deletions

View file

@ -299,7 +299,7 @@ proc semArrayIndex(c: PContext, n: PNode): PType =
result = makeRangeWithStaticExpr(c, e.typ.n)
elif e.kind in {nkIntLit..nkUInt64Lit}:
if e.intVal < 0:
localError(c.config, n[1].info,
localError(c.config, n.info,
"Array length can't be negative, but was " & $e.intVal)
result = makeRangeType(c, 0, e.intVal-1, n.info, e.typ)
elif e.kind == nkSym and e.typ.kind == tyStatic: