Relax the restrictions on the index types (#9412)

This commit is contained in:
LemonBoy
2018-10-18 11:08:05 +02:00
committed by Andreas Rumpf
parent 458aab0b10
commit 6ef198e07b
2 changed files with 18 additions and 20 deletions

View File

@@ -533,6 +533,9 @@ block t7818:
doAssert(testOpenArray(@[u.addr, v.addr, w.addr]) == "123")
doAssert(testOpenArray(@[w.addr, u.addr, v.addr]) == "312")
# regression regarding unchecked array indexing:
proc foo(x: ptr UncheckedArray[int]; idx: uint64) =
echo x[idx]
block trelaxedindextyp:
# any integral type is allowed as index
proc foo(x: ptr UncheckedArray[int]; idx: uint64) = echo x[idx]
proc foo(x: seq[int]; idx: uint64) = echo x[idx]
proc foo(x: string|cstring; idx: uint64) = echo x[idx]
proc foo(x: openArray[int]; idx: uint64) = echo x[idx]