Remove warnings in Nim 1.0.2
This commit is contained in:
parent
173c7b4a86
commit
88b79e2300
|
@ -1,5 +1,5 @@
|
|||
import
|
||||
strutils, unicode,
|
||||
unicode,
|
||||
faststreams/input_stream, stew/objects,
|
||||
types
|
||||
|
||||
|
@ -55,8 +55,6 @@ type
|
|||
strVal*: string
|
||||
|
||||
const
|
||||
pageSize = 4096
|
||||
|
||||
powersOfTen = [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
|
||||
1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
|
||||
1e20, 1e21, 1e22] # TODO: this table should be much larger
|
||||
|
@ -276,7 +274,7 @@ proc scanNumber(lexer: var JsonLexer) =
|
|||
lexer.tok = tkInt
|
||||
let scannedValue = lexer.scanInt()
|
||||
checkForNonPortableInt scannedValue
|
||||
lexer.intVal = int64(scannedValue)
|
||||
lexer.intVal = int64(scannedValue) * sign
|
||||
if lexer.stream[].eof: return
|
||||
c = lexer.stream[].peek()
|
||||
if c == '.':
|
||||
|
|
|
@ -144,7 +144,7 @@ iterator readObject*(r: var JsonReader, KeyType: typedesc, ValueType: typedesc):
|
|||
proc readValue*(r: var JsonReader, value: var auto) =
|
||||
mixin readValue
|
||||
|
||||
let tok = r.lexer.tok
|
||||
let tok {.used.} = r.lexer.tok
|
||||
|
||||
when value is string:
|
||||
r.requireToken tkString
|
||||
|
|
|
@ -127,9 +127,6 @@ proc writeArray[T](w: var JsonWriter, elements: openarray[T]) =
|
|||
proc writeValue*(w: var JsonWriter, value: auto) =
|
||||
mixin enumInstanceSerializedFields, writeValue, writeFieldIMPL
|
||||
|
||||
template addChar(c) =
|
||||
append c
|
||||
|
||||
when value is JsonNode:
|
||||
append if w.hasPrettyOutput: value.pretty
|
||||
else: $value
|
||||
|
@ -141,11 +138,11 @@ proc writeValue*(w: var JsonWriter, value: auto) =
|
|||
else:
|
||||
writeValue(w, value[])
|
||||
elif value is string|cstring:
|
||||
addChar '"'
|
||||
append '"'
|
||||
|
||||
template addPrefixSlash(c) =
|
||||
addChar '\\'
|
||||
addChar c
|
||||
append '\\'
|
||||
append c
|
||||
|
||||
for c in value:
|
||||
case c
|
||||
|
@ -165,9 +162,9 @@ proc writeValue*(w: var JsonWriter, value: auto) =
|
|||
# This is potentially a bug in Nim's json module.
|
||||
append $ord(c)
|
||||
of '\\': addPrefixSlash '\\'
|
||||
else: addChar c
|
||||
else: append c
|
||||
|
||||
addChar '"'
|
||||
append '"'
|
||||
elif value is bool:
|
||||
append if value: "true" else: "false"
|
||||
elif value is enum:
|
||||
|
|
|
@ -26,7 +26,7 @@ type
|
|||
# properly when it's placed in another module:
|
||||
Meter.borrowSerialization int
|
||||
|
||||
template reject(code) =
|
||||
template reject(code) {.used.} =
|
||||
static: doAssert(not compiles(code))
|
||||
|
||||
proc `==`(lhs, rhs: Meter): bool =
|
||||
|
@ -45,11 +45,11 @@ proc newSimple(x: int, y: string, d: Meter): ref Simple =
|
|||
result.y = y
|
||||
result.distance = d
|
||||
|
||||
when false:
|
||||
var invalid = Invalid(distance: Mile(100))
|
||||
# The compiler cannot handle this check at the moment
|
||||
# {.fatal.} seems fatal even in `compiles` context
|
||||
var invalid = Invalid(distance: Mile(100))
|
||||
reject invalid.toJson
|
||||
when false: reject invalid.toJson
|
||||
else: discard invalid
|
||||
|
||||
suite "toJson tests":
|
||||
test "encode primitives":
|
||||
|
|
Loading…
Reference in New Issue