Skip to content

Commit

Permalink
Remove the uses of {.procvar.} pragma (nim-lang#14359)
Browse files Browse the repository at this point in the history
This pragma did nothing.

Ref:
- nim-lang#2172 (comment)
- nim-lang#12975
  • Loading branch information
kaushalmodi authored and EchoPouet committed Jun 13, 2020
1 parent f4e278c commit 3d61b16
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 68 deletions.
4 changes: 2 additions & 2 deletions lib/packages/docutils/rst.nim
Expand Up @@ -305,14 +305,14 @@ proc whichMsgClass*(k: MsgKind): MsgClass =
else: assert false, "msgkind does not fit naming scheme"

proc defaultMsgHandler*(filename: string, line, col: int, msgkind: MsgKind,
arg: string) {.procvar.} =
arg: string) =
let mc = msgkind.whichMsgClass
let a = messages[msgkind] % arg
let message = "$1($2, $3) $4: $5" % [filename, $line, $col, $mc, a]
if mc == mcError: raise newException(EParseError, message)
else: writeLine(stdout, message)

proc defaultFindFile*(filename: string): string {.procvar.} =
proc defaultFindFile*(filename: string): string =
if existsFile(filename): result = filename
else: result = ""

Expand Down
4 changes: 2 additions & 2 deletions lib/pure/asyncftpclient.nim
Expand Up @@ -322,7 +322,7 @@ proc getFile(ftp: AsyncFtpClient, file: File, total: BiggestInt,
assertReply(await(ftp.expectReply()), "226")

proc defaultOnProgressChanged*(total, progress: BiggestInt,
speed: float): Future[void] {.nimcall, gcsafe, procvar.} =
speed: float): Future[void] {.nimcall, gcsafe.} =
## Default FTP ``onProgressChanged`` handler. Does nothing.
result = newFuture[void]()
#echo(total, " ", progress, " ", speed)
Expand Down Expand Up @@ -358,7 +358,7 @@ proc doUpload(ftp: AsyncFtpClient, file: File,
var countdownFut = sleepAsync(1000)
var sendFut: Future[void] = nil
while ftp.dsockConnected:
if sendFut == nil or sendFut.finished:
if sendFut == nil or sendFut.finished:
# TODO: Async file reading.
let len = file.readBuffer(addr(data[0]), 4000)
setLen(data, len)
Expand Down
2 changes: 1 addition & 1 deletion lib/pure/rationals.nim
Expand Up @@ -225,7 +225,7 @@ proc `/=`*[T](x: var Rational[T], y: T) =
x.den *= y
reduce(x)

proc cmp*(x, y: Rational): int {.procvar.} =
proc cmp*(x, y: Rational): int =
## Compares two rationals.
(x - y).num

Expand Down
7 changes: 3 additions & 4 deletions lib/pure/strmisc.nim
Expand Up @@ -12,8 +12,7 @@

import strutils

proc expandTabs*(s: string, tabSize: int = 8): string {.noSideEffect,
procvar.} =
proc expandTabs*(s: string, tabSize: int = 8): string {.noSideEffect.} =
## Expand tab characters in `s` replacing them by spaces.
##
## The amount of inserted spaces for each tab character is the difference
Expand Down Expand Up @@ -53,7 +52,7 @@ proc expandTabs*(s: string, tabSize: int = 8): string {.noSideEffect,

proc partition*(s: string, sep: string,
right: bool = false): (string, string, string)
{.noSideEffect, procvar.} =
{.noSideEffect.} =
## Split the string at the first or last occurrence of `sep` into a 3-tuple
##
## Returns a 3 string tuple of (beforeSep, `sep`, afterSep) or
Expand All @@ -72,7 +71,7 @@ proc partition*(s: string, sep: string,
return if right: ("", "", s) else: (s, "", "")

proc rpartition*(s: string, sep: string): (string, string, string)
{.noSideEffect, procvar.} =
{.noSideEffect.} =
## Split the string at the last occurrence of `sep` into a 3-tuple
##
## Returns a 3 string tuple of (beforeSep, `sep`, afterSep) or
Expand Down
48 changes: 24 additions & 24 deletions lib/pure/strutils.nim
Expand Up @@ -119,7 +119,7 @@ const
## doAssert "01234".find(invalid) == -1
## doAssert "01A34".find(invalid) == 2

proc isAlphaAscii*(c: char): bool {.noSideEffect, procvar,
proc isAlphaAscii*(c: char): bool {.noSideEffect,
rtl, extern: "nsuIsAlphaAsciiChar".} =
## Checks whether or not character `c` is alphabetical.
##
Expand All @@ -131,7 +131,7 @@ proc isAlphaAscii*(c: char): bool {.noSideEffect, procvar,
doAssert isAlphaAscii('8') == false
return c in Letters

proc isAlphaNumeric*(c: char): bool {.noSideEffect, procvar,
proc isAlphaNumeric*(c: char): bool {.noSideEffect,
rtl, extern: "nsuIsAlphaNumericChar".} =
## Checks whether or not `c` is alphanumeric.
##
Expand All @@ -142,7 +142,7 @@ proc isAlphaNumeric*(c: char): bool {.noSideEffect, procvar,
doAssert isAlphaNumeric(' ') == false
return c in Letters+Digits

proc isDigit*(c: char): bool {.noSideEffect, procvar,
proc isDigit*(c: char): bool {.noSideEffect,
rtl, extern: "nsuIsDigitChar".} =
## Checks whether or not `c` is a number.
##
Expand All @@ -152,7 +152,7 @@ proc isDigit*(c: char): bool {.noSideEffect, procvar,
doAssert isDigit('8') == true
return c in Digits

proc isSpaceAscii*(c: char): bool {.noSideEffect, procvar,
proc isSpaceAscii*(c: char): bool {.noSideEffect,
rtl, extern: "nsuIsSpaceAsciiChar".} =
## Checks whether or not `c` is a whitespace character.
runnableExamples:
Expand All @@ -161,7 +161,7 @@ proc isSpaceAscii*(c: char): bool {.noSideEffect, procvar,
doAssert isSpaceAscii('\t') == true
return c in Whitespace

proc isLowerAscii*(c: char): bool {.noSideEffect, procvar,
proc isLowerAscii*(c: char): bool {.noSideEffect,
rtl, extern: "nsuIsLowerAsciiChar".} =
## Checks whether or not `c` is a lower case character.
##
Expand All @@ -176,7 +176,7 @@ proc isLowerAscii*(c: char): bool {.noSideEffect, procvar,
doAssert isLowerAscii('7') == false
return c in {'a'..'z'}

proc isUpperAscii*(c: char): bool {.noSideEffect, procvar,
proc isUpperAscii*(c: char): bool {.noSideEffect,
rtl, extern: "nsuIsUpperAsciiChar".} =
## Checks whether or not `c` is an upper case character.
##
Expand All @@ -192,7 +192,7 @@ proc isUpperAscii*(c: char): bool {.noSideEffect, procvar,
return c in {'A'..'Z'}


proc toLowerAscii*(c: char): char {.noSideEffect, procvar,
proc toLowerAscii*(c: char): char {.noSideEffect,
rtl, extern: "nsuToLowerAsciiChar".} =
## Returns the lower case version of character ``c``.
##
Expand All @@ -216,7 +216,7 @@ template toImpl(call) =
for i in 0..len(s) - 1:
result[i] = call(s[i])

proc toLowerAscii*(s: string): string {.noSideEffect, procvar,
proc toLowerAscii*(s: string): string {.noSideEffect,
rtl, extern: "nsuToLowerAsciiStr".} =
## Converts string `s` into lower case.
##
Expand All @@ -230,7 +230,7 @@ proc toLowerAscii*(s: string): string {.noSideEffect, procvar,
doAssert toLowerAscii("FooBar!") == "foobar!"
toImpl toLowerAscii

proc toUpperAscii*(c: char): char {.noSideEffect, procvar,
proc toUpperAscii*(c: char): char {.noSideEffect,
rtl, extern: "nsuToUpperAsciiChar".} =
## Converts character `c` into upper case.
##
Expand All @@ -250,7 +250,7 @@ proc toUpperAscii*(c: char): char {.noSideEffect, procvar,
else:
result = c

proc toUpperAscii*(s: string): string {.noSideEffect, procvar,
proc toUpperAscii*(s: string): string {.noSideEffect,
rtl, extern: "nsuToUpperAsciiStr".} =
## Converts string `s` into upper case.
##
Expand All @@ -264,7 +264,7 @@ proc toUpperAscii*(s: string): string {.noSideEffect, procvar,
doAssert toUpperAscii("FooBar!") == "FOOBAR!"
toImpl toUpperAscii

proc capitalizeAscii*(s: string): string {.noSideEffect, procvar,
proc capitalizeAscii*(s: string): string {.noSideEffect,
rtl, extern: "nsuCapitalizeAscii".} =
## Converts the first character of string `s` into upper case.
##
Expand Down Expand Up @@ -299,7 +299,7 @@ proc nimIdentNormalize*(s: string): string =
inc j
if j != s.len: setLen(result, j)

proc normalize*(s: string): string {.noSideEffect, procvar,
proc normalize*(s: string): string {.noSideEffect,
rtl, extern: "nsuNormalize".} =
## Normalizes the string `s`.
##
Expand All @@ -323,7 +323,7 @@ proc normalize*(s: string): string {.noSideEffect, procvar,
if j != s.len: setLen(result, j)

proc cmpIgnoreCase*(a, b: string): int {.noSideEffect,
rtl, extern: "nsuCmpIgnoreCase", procvar.} =
rtl, extern: "nsuCmpIgnoreCase".} =
## Compares two strings in a case insensitive manner. Returns:
##
## | 0 if a == b
Expand All @@ -345,7 +345,7 @@ proc cmpIgnoreCase*(a, b: string): int {.noSideEffect,
# thus we compile without checks here

proc cmpIgnoreStyle*(a, b: string): int {.noSideEffect,
rtl, extern: "nsuCmpIgnoreStyle", procvar.} =
rtl, extern: "nsuCmpIgnoreStyle".} =
## Semantically the same as ``cmp(normalize(a), normalize(b))``. It
## is just optimized to not allocate temporary strings. This should
## NOT be used to compare Nim identifier names.
Expand Down Expand Up @@ -1096,7 +1096,7 @@ proc intToStr*(x: int, minchars: Positive = 1): string {.noSideEffect,
if x < 0:
result = '-' & result

proc parseInt*(s: string): int {.noSideEffect, procvar,
proc parseInt*(s: string): int {.noSideEffect,
rtl, extern: "nsuParseInt".} =
## Parses a decimal integer value contained in `s`.
##
Expand All @@ -1107,7 +1107,7 @@ proc parseInt*(s: string): int {.noSideEffect, procvar,
if L != s.len or L == 0:
raise newException(ValueError, "invalid integer: " & s)

proc parseBiggestInt*(s: string): BiggestInt {.noSideEffect, procvar,
proc parseBiggestInt*(s: string): BiggestInt {.noSideEffect,
rtl, extern: "nsuParseBiggestInt".} =
## Parses a decimal integer value contained in `s`.
##
Expand All @@ -1116,7 +1116,7 @@ proc parseBiggestInt*(s: string): BiggestInt {.noSideEffect, procvar,
if L != s.len or L == 0:
raise newException(ValueError, "invalid integer: " & s)

proc parseUInt*(s: string): uint {.noSideEffect, procvar,
proc parseUInt*(s: string): uint {.noSideEffect,
rtl, extern: "nsuParseUInt".} =
## Parses a decimal unsigned integer value contained in `s`.
##
Expand All @@ -1125,7 +1125,7 @@ proc parseUInt*(s: string): uint {.noSideEffect, procvar,
if L != s.len or L == 0:
raise newException(ValueError, "invalid unsigned integer: " & s)

proc parseBiggestUInt*(s: string): BiggestUInt {.noSideEffect, procvar,
proc parseBiggestUInt*(s: string): BiggestUInt {.noSideEffect,
rtl, extern: "nsuParseBiggestUInt".} =
## Parses a decimal unsigned integer value contained in `s`.
##
Expand All @@ -1134,7 +1134,7 @@ proc parseBiggestUInt*(s: string): BiggestUInt {.noSideEffect, procvar,
if L != s.len or L == 0:
raise newException(ValueError, "invalid unsigned integer: " & s)

proc parseFloat*(s: string): float {.noSideEffect, procvar,
proc parseFloat*(s: string): float {.noSideEffect,
rtl, extern: "nsuParseFloat".} =
## Parses a decimal floating point value contained in `s`.
##
Expand All @@ -1147,7 +1147,7 @@ proc parseFloat*(s: string): float {.noSideEffect, procvar,
if L != s.len or L == 0:
raise newException(ValueError, "invalid float: " & s)

proc parseBinInt*(s: string): int {.noSideEffect, procvar,
proc parseBinInt*(s: string): int {.noSideEffect,
rtl, extern: "nsuParseBinInt".} =
## Parses a binary integer value contained in `s`.
##
Expand Down Expand Up @@ -1176,7 +1176,7 @@ proc parseOctInt*(s: string): int {.noSideEffect,
if L != s.len or L == 0:
raise newException(ValueError, "invalid oct integer: " & s)

proc parseHexInt*(s: string): int {.noSideEffect, procvar,
proc parseHexInt*(s: string): int {.noSideEffect,
rtl, extern: "nsuParseHexInt".} =
## Parses a hexadecimal integer value contained in `s`.
##
Expand All @@ -1202,7 +1202,7 @@ proc generateHexCharToValueMap(): string =

const hexCharToValueMap = generateHexCharToValueMap()

proc parseHexStr*(s: string): string {.noSideEffect, procvar,
proc parseHexStr*(s: string): string {.noSideEffect,
rtl, extern: "nsuParseHexStr".} =
## Convert hex-encoded string to byte string, e.g.:
##
Expand Down Expand Up @@ -2918,12 +2918,12 @@ iterator tokenize*(s: string, seps: set[char] = Whitespace): tuple[
break
i = j

proc isEmptyOrWhitespace*(s: string): bool {.noSideEffect, procvar, rtl,
proc isEmptyOrWhitespace*(s: string): bool {.noSideEffect, rtl,
extern: "nsuIsEmptyOrWhitespace".} =
## Checks if `s` is empty or consists entirely of whitespace characters.
result = s.allCharsInSet(Whitespace)

proc isNilOrWhitespace*(s: string): bool {.noSideEffect, procvar, rtl,
proc isNilOrWhitespace*(s: string): bool {.noSideEffect, rtl,
extern: "nsuIsNilOrWhitespace",
deprecated: "use isEmptyOrWhitespace instead".} =
## Alias for isEmptyOrWhitespace
Expand Down

0 comments on commit 3d61b16

Please sign in to comment.