remove deprecated procs (#12535)

This commit is contained in:
Andreas Rumpf 2019-11-05 11:05:46 +01:00 • committed by Miran
commit 3ba3307d61
39 changed files with 111 additions and 567 deletions

View file

@ -203,11 +203,11 @@ when defined(windows):
add(result, c)
proc sendMessages(client: AsyncFD) {.async.} =
for i in 0 .. <messagesToSend:
for i in 0 ..< messagesToSend:
await winSend(client, "Message " & $i & "\c\L")
proc launchSwarm(port: Port) {.async.} =
for i in 0 .. <swarmSize:
for i in 0 ..< swarmSize:
var sock = newNativeSocket()
setBlocking(sock, false)

View file

@ -14,6 +14,6 @@ s.add x
s.add s[s.high]
s.add s[s.len-1]
s.add s[s.xlen-1]
s.add s[s.len-1]
echo s # @[5, 5, 0]

View file

@ -16,8 +16,8 @@ type
AnyTransform3D* = AnyMatrix[4, 4, float]
proc transposed*(m: AnyMatrix): m.TransposedType =
for r in 0 .. <m.R:
for c in 0 .. <m.C:
for r in 0 ..< m.R:
for c in 0 ..< m.C:
result[r, c] = m[c, r]
proc determinant*(m: AnySquareMatrix): int =

View file

@ -9,23 +9,27 @@ proc test(foo: Foo[int])
required type for foo: Foo[int]
but expression 'bar' is of type: Bar[system.int]
t3330.nim(63, 8) Hint: Non-matching candidates for add(k, string, T)
proc add[T](x: var seq[T]; y: T)
first type mismatch at position: 1
required type for x: var seq[T]
but expression 'k' is of type: Alias
proc add(x: var string; y: string)
first type mismatch at position: 1
required type for x: var string
but expression 'k' is of type: Alias
proc add[T](x: var seq[T]; y: openArray[T])
first type mismatch at position: 1
required type for x: var seq[T]
but expression 'k' is of type: Alias
proc add(result: var string; x: float)
first type mismatch at position: 1
required type for result: var string
but expression 'k' is of type: Alias
proc add(x: var string; y: char)
proc add[T](x: var seq[T]; y: T)
first type mismatch at position: 1
required type for x: var seq[T]
but expression 'k' is of type: Alias
proc add(x: var string; y: cstring)
first type mismatch at position: 1
required type for x: var string
but expression 'k' is of type: Alias
proc add(x: var string; y: cstring)
proc add(x: var string; y: char)
first type mismatch at position: 1
required type for x: var string
but expression 'k' is of type: Alias
@ -33,10 +37,6 @@ proc add(result: var string; x: int64)
first type mismatch at position: 1
required type for result: var string
but expression 'k' is of type: Alias
proc add[T](x: var seq[T]; y: openArray[T])
first type mismatch at position: 1
required type for x: var seq[T]
but expression 'k' is of type: Alias
t3330.nim(63, 8) template/generic instantiation of `add` from here
t3330.nim(70, 6) Foo: 'bar.value' cannot be assigned to

View file

@ -410,7 +410,7 @@ macro wrapErrorChecking(f: stmt): stmt {.immediate.} =
body = newStmtList glProc
returnsSomething = child.params[0].kind != nnkEmpty
callParams = newSeq[when defined(nimnode): NimNode else: PNimrodNode]()
for param in params[1 .. <params.len]:
for param in params[1 ..< params.len]:
callParams.add param[0]
let glCall = newCall(glProc.name, callParams)

View file

@ -1,9 +1,9 @@
discard """
cmd: '''nim c --newruntime $file'''
output: '''443 443'''
output: '''422 422'''
"""
import strutils, os
import strutils, os, std / wordwrap
import core / allocators
import system / ansi_c
@ -76,12 +76,12 @@ proc staticTests =
inp = """ this is a long text -- muchlongerthan10chars and here
it goes"""
outp = " this is a\nlong text\n--\nmuchlongerthan10chars\nand here\nit goes"
doAssert wordWrap(inp, 10, false) == outp
doAssert wrapWords(inp, 10, false) == outp
let
longInp = """ThisIsOneVeryLongStringWhichWeWillSplitIntoEightSeparatePartsNow"""
longOutp = "ThisIsOn\neVeryLon\ngStringW\nhichWeWi\nllSplitI\nntoEight\nSeparate\nPartsNow"
doAssert wordWrap(longInp, 8, true) == longOutp
doAssert wrapWords(longInp, 8, true) == longOutp
doAssert "$animal eats $food." % ["animal", "The cat", "food", "fish"] ==
"The cat eats fish."

View file

@ -22,10 +22,10 @@ proc newFoo*(): ref TFoo =
alive_foos.add result.id
inc foo_counter
for i in 0 .. <10:
for i in 0 ..< 10:
discard newFoo()
for i in 0 .. <10:
for i in 0 ..< 10:
let f = newFoo()
f.fn = proc =
echo f.id

View file

@ -40,7 +40,7 @@ when true:
@[2, 3]]
iterator threadUniqs(seq1: seq[seq[int]]): seq[seq[int]] =
for i in 0 .. <seq1.len:
for i in 0 ..< seq1.len:
block:
let i = i
yield seq1.filter do (x: seq[int]) -> bool: x[0] == seq1[i][0]

View file

@ -8,7 +8,7 @@ proc convertReturns(node, retFutureSym: NimNode): NimNode {.compileTime.} =
result = newCall(newIdentNode("complete"), retFutureSym, node[0])
else:
result = node
for i in 0 .. <node.len:
for i in 0 ..< node.len:
result[i] = convertReturns(node[i], retFutureSym)
macro async2(prc: untyped): untyped =
@ -51,7 +51,7 @@ macro async2(prc: untyped): untyped =
result = prc
# Remove the 'closure' pragma.
for i in 0 .. <result[4].len:
for i in 0 ..< result[4].len:
if result[4][i].ident == !"async":
result[4].del(i)

View file

@ -197,7 +197,7 @@ proc lobbyInit*() =
messageArea.scrollBack -= 1
update(messageArea))
gui.newButton(text = "Flood msg area", position = vec2f(185, 30), onClick = proc(b: PButton) =
for i in 0.. <30:
for i in 0..< 30:
dispMessage($i))"""
dirServer = newServer()
dirServer.addHandler HChat, handleChat

View file

@ -243,7 +243,7 @@ proc lobbyInit*() =
messageArea.scrollBack -= 1
update(messageArea))
gui.newButton(text = "Flood msg area", position = vec2f(185, 30), onClick = proc(b: PButton) =
for i in 0.. <30:
for i in 0..< 30:
dispMessage($i))
var i = 0

View file

@ -61,7 +61,7 @@ proc newPrimitive*(verts: var seq[TVert],
color=white(),
z: TZ_range=0): PPrimitive =
var indices = newSeq[GLushort](verts.len)
for i in 0 .. <verts.len:
for i in 0 ..< verts.len:
indices[i] = i.GLushort
new(result)
@ -108,7 +108,7 @@ proc updVerts*(o: PPrimitive, start, `end`: int, f: proc(i: int, vert: var TVert
cast[GLvoid](cast[int](o.verts[0].addr) + byteOffset))
proc updAllVerts(o: PPrimitive, f: proc(i: int, vert: var TVert)) =
for i in 0 .. <o.verts.len:
for i in 0 ..< o.verts.len:
f(i, o.verts[i])
?glBindBuffer(GLarrayBuffer, o.arrBufId)
@ -132,7 +132,7 @@ proc newVertCircle*(circle: TCircle, nSegs: Natural=0): seq[TVert] =
result = newSeq[TVert](nSegs)
#result[0] = newVert(circle.p, newV2xy(0.5))
for i in 1 .. <nSegs:
for i in 1 ..< nSegs:
let pos = newV2(x + circle.p.x, y + circle.p.y)
let texCoord = pos * newV2xy(1.0 / circle.r)

View file

@ -14,7 +14,7 @@ type
# TODO: Change to TVT when compiler issue is resolved.
proc `$`*[T](o: TV2[T]): string =
result = "("
for i in 0 .. <o.len:
for i in 0 ..< o.len:
result &= $o[0]
if i != o.len - 1:
result &= ", "
@ -47,7 +47,7 @@ proc `+`*(lhs: TV2[TR], rhs: TV2[TR]): TV2[TR] =
# result += a[i] * b[i]
proc dot[T](a, b: TV2[T]): T =
for i in 0 .. <a.len:
for i in 0 ..< a.len:
result += a[i] * b[i]
assert dot(newV2(), newV2()) == 0.0

View file

@ -61,7 +61,7 @@ proc row*(a: TMatrix; i: int): auto =
proc col*(a: TMatrix; j: int): auto =
result = TVec[TMatrix.N, TMatrix.T]()
for idx in 0 .. <TMatrix.N:
for idx in 0 ..< TMatrix.N:
result.data[idx] = a.data[(TMatrix.N * (idx)) + (j-1)]
proc mul*(a: TMat4f; b: TMat4f): TMat4f =

View file

@ -39,7 +39,7 @@ proc cmpPlatforms(a, b: string): int =
proc sorted[T](a: openArray[T]): bool =
result = true
for i in 0 .. < a.high:
for i in 0 ..< a.high:
if cmpPlatforms(a[i], a[i+1]) > 0:
echo "Out of order: ", a[i], " ", a[i+1]
result = false

View file

@ -24,5 +24,5 @@ write(stdout, ack(5, 4))
# bug #1442
let h=3
for x in 0.. <h.int:
for x in 0 ..< h.int:
echo x

View file

@ -19,7 +19,7 @@ proc showNumber(num: int | float) =
showNumber(3.14)
showNumber(42)
for i in 0 .. <10:
for i in 0 ..< 10:
echo(i)
block: # Block added due to clash.

View file

@ -202,7 +202,7 @@ block:
block:
let list = @[4, 8, 15, 16, 23, 42]
for i in 0 .. <list.len:
for i in 0 ..< list.len:
stdout.write($list[i] & " ")
var collection: set[int16]
@ -366,4 +366,4 @@ block:
Color {.pure.} = enum
red, green, blue
let color = Color.red
let color = Color.red

View file

@ -46,7 +46,7 @@ assert obj["username"].str == "Dominik"
block:
proc count10(): int =
for i in 0 .. <10:
for i in 0 ..< 10:
result.inc
assert count10() == 10

View file

@ -67,9 +67,9 @@ proc readChunks(filename: string, chunksize = 1000000): Stats =
# Find where the last line ends
chunkLen.dec
responses.add(spawn parse(buffer[0 .. <chunkLen]))
responses.add(spawn parse(buffer[0 ..< chunkLen]))
oldBufferLen = readSize - chunkLen
buffer[0 .. <oldBufferLen] = buffer[readSize - oldBufferLen .. ^1]
buffer[0 ..< oldBufferLen] = buffer[readSize - oldBufferLen .. ^1]
for resp in responses:
let statistic = ^resp

View file

@ -51,9 +51,9 @@ proc readChunks(filename: string, chunksize = 1000000): Stats =
# Find where the last line ends
chunkLen.dec
responses.add(spawn parse(buffer[0 .. <chunkLen]))
responses.add(spawn parse(buffer[0 ..< chunkLen]))
oldBufferLen = readSize - chunkLen
buffer[0 .. <oldBufferLen] = buffer[readSize - oldBufferLen .. ^1]
buffer[0 ..< oldBufferLen] = buffer[readSize - oldBufferLen .. ^1]
echo("Spawns: ", responses.len)
for resp in responses:

View file

@ -58,9 +58,9 @@ proc readPageCounts(filename: string, chunkSize = 1_000_000) =
while chunkLen >= 0 and buffer[chunkLen - 1] notin NewLines:
chunkLen.dec
responses.add(spawn parseChunk(buffer[0 .. <chunkLen]))
responses.add(spawn parseChunk(buffer[0 ..< chunkLen]))
oldBufferLen = readSize - chunkLen
buffer[0 .. <oldBufferLen] = buffer[readSize - oldBufferLen .. ^1]
buffer[0 ..< oldBufferLen] = buffer[readSize - oldBufferLen .. ^1]
var mostPopular = newStats()
for resp in responses:

View file

@ -7,7 +7,7 @@ import threadpool
var counter = 0
proc increment(x: int) =
for i in 0 .. <x:
for i in 0 ..< x:
let value = counter + 1
counter = value

View file

@ -10,7 +10,7 @@ initLock(counterLock)
var counter {.guard: counterLock.} = 0
proc increment(x: int) =
for i in 0 .. <x:
for i in 0 ..< x:
let value = counter + 1
counter = value

View file

@ -79,9 +79,9 @@ proc findMessages*(database: Database, usernames: seq[string],
result = @[]
if usernames.len == 0: return
var whereClause = " WHERE "
for i in 0 .. <usernames.len:
for i in 0 ..< usernames.len:
whereClause.add("username = ? ")
if i != <usernames.len:
if i != usernames.high:
whereClause.add("or ")
let messages = database.db.getAllRows(

View file

@ -26,9 +26,9 @@ proc greet(p:Person) =
" friend:", p.friend.name, "(", cast[int](addr p.friend.name),") }"
proc setup =
for i in 0 .. <20:
for i in 0 ..< 20:
people.add newPerson("Person" & $(i + 1))
for i in 0 .. <20:
for i in 0 ..< 20:
people[i].friend = people[19-i]
proc update =

View file

@ -35,9 +35,9 @@ proc main =
parallel:
for n in nums: # Error: cannot prove: i <= len(nums) + -1
spawn log(n)
#for i in 0 .. <nums.len: # Error: cannot prove: i <= len(nums) + -1
#for i in 0 ..< nums.len: # Error: cannot prove: i <= len(nums) + -1
#for i in 0 .. nums.len-1: # WORKS!
#for i in 0 .. <nums.len: # WORKS!
#for i in 0 ..< nums.len: # WORKS!
# spawn log(nums[i])
# Array needs explicit size to work, probably related to issue #2287

View file

@ -1,56 +0,0 @@
discard """
output: "Success"
target: "c"
"""
# Note: target: "cpp" fails because we can't yet have `extern "C"` mangling in
# `exportc` procs.
import math, random, threadPool
# ---
type
Person = object
age: int
friend: ref Person
var
people: seq[ref Person] = @[]
proc newPerson(age:int): ref Person =
result.new()
result.age = age
proc greet(p:Person) =
#echo p.age, ", ", p.friend.age
p.friend.age += 1
# ---
proc setup =
for i in 0 .. <20:
people.add newPerson(i + 1)
for i in 0 .. <20:
people[i].friend = people[random(20)]
proc update =
var countA: array[20, int]
var countB: array[20, int]
for i, p in people:
countA[i] = getRefCount(p)
parallel:
for i in 0 .. people.high:
spawn greet(people[i][])
for i, p in people:
countB[i] = getRefCount(p)
for i in 0 .. <20:
doAssert countA[i] == countB[i]
echo "Success"
# ---
when true:
setup()
update()

View file

@ -47,7 +47,7 @@ proc filter[T](a: openarray[T], predicate: proc (x: T): bool): seq[T] =
proc map[T, S](a: openarray[T], fn: proc (x: T): S): seq[S] =
newSeq(result, a.len)
for i in 0 .. <a.len: result[i] = fn(a[i])
for i in 0 ..< a.len: result[i] = fn(a[i])
type

View file

@ -46,7 +46,7 @@ type
Vect[N: static[int], A] = array[N, A]
proc push[N: static[int], A](a: Vect[N, A], x: A): Vect[N + 1, A] =
for n in 0 .. < N:
for n in 0 ..< N:
result[n] = a[n]
result[N] = x

View file

@ -155,24 +155,6 @@ proc testDelete =
delete(s, 0, 0)
assert s == "1236789ABCDEFG"
proc testIsAlphaNumeric =
assert isAlphaNumeric("abcdABC1234") == true
assert isAlphaNumeric("a") == true
assert isAlphaNumeric("abcABC?1234") == false
assert isAlphaNumeric("abcABC 1234") == false
assert isAlphaNumeric(".") == false
testIsAlphaNumeric()
proc testIsDigit =
assert isDigit("1") == true
assert isDigit("1234") == true
assert isDigit("abcABC?1234") == false
assert isDigit(".") == false
assert isDigit(":") == false
testIsDigit()
proc testFind =
assert "0123456789ABCDEFGH".find('A') == 10
assert "0123456789ABCDEFGH".find('A', 5) == 10
@ -273,15 +255,6 @@ assert(insertSep($232) == "232")
assert(insertSep($12345, ',') == "12,345")
assert(insertSep($0) == "0")
assert(editDistance("prefix__hallo_suffix", "prefix__hallo_suffix") == 0)
assert(editDistance("prefix__hallo_suffix", "prefix__hallo_suffi1") == 1)
assert(editDistance("prefix__hallo_suffix", "prefix__HALLO_suffix") == 5)
assert(editDistance("prefix__hallo_suffix", "prefix__ha_suffix") == 3)
assert(editDistance("prefix__hallo_suffix", "prefix") == 14)
assert(editDistance("prefix__hallo_suffix", "suffix") == 14)
assert(editDistance("prefix__hallo_suffix", "prefix__hao_suffix") == 2)
assert(editDistance("main", "malign") == 2)
assert "/1/2/3".rfind('/') == 4
assert "/1/2/3".rfind('/', last=1) == 0
assert "/1/2/3".rfind('0') == -1
@ -307,7 +280,7 @@ assert "".toHex == ""
assert "\x00\xFF\x80".toHex == "00FF80"
assert "0123456789abcdef".parseHexStr.toHex == "0123456789ABCDEF"
assert(' '.repeat(8)== " ")
assert(' '.repeat(8) == " ")
assert(" ".repeat(8) == " ")
assert(spaces(8) == " ")