diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-05-01 15:44:23 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-05-02 13:34:54 +0200 |
commit | 74fe7a800b0c2ade3260b8a2f7bc72ea4fd8dc03 (patch) | |
tree | 9cace45a8f3fcfa255061a7d9ea208e58ec85f61 | |
parent | 5ac94d26b3691395c40d93109d85fe29d1f14db1 (diff) | |
download | Nim-74fe7a800b0c2ade3260b8a2f7bc72ea4fd8dc03.tar.gz |
make tests green again
19 files changed, 103 insertions, 103 deletions
diff --git a/lib/system/embedded.nim b/lib/system/embedded.nim index a14f43e7e..46e84e056 100644 --- a/lib/system/embedded.nim +++ b/lib/system/embedded.nim @@ -40,4 +40,4 @@ proc reraiseException() {.compilerRtl.} = proc writeStackTrace() = discard -proc setControlCHook(hook: proc () {.noconv.} not nil) = discard +proc setControlCHook(hook: proc () {.noconv.}) = discard diff --git a/tests/compiles/trecursive_generic_in_compiles.nim b/tests/compiles/trecursive_generic_in_compiles.nim index 77bf0bb02..9c7fd10b3 100644 --- a/tests/compiles/trecursive_generic_in_compiles.nim +++ b/tests/compiles/trecursive_generic_in_compiles.nim @@ -1,6 +1,6 @@ # bug #3313 -import unittest, future - +import unittest, sugar +{.experimental: "notnil".} type ListNodeKind = enum lnkNil, lnkCons diff --git a/tests/constructors/tinvalid_construction.nim b/tests/constructors/tinvalid_construction.nim index bb3b1bebb..b3e56eec6 100644 --- a/tests/constructors/tinvalid_construction.nim +++ b/tests/constructors/tinvalid_construction.nim @@ -3,12 +3,12 @@ template accept(x) = template reject(x) = static: assert(not compiles(x)) - +{.experimental: "notnil".} type TRefObj = ref object x: int - THasNotNils = object of TObject + THasNotNils = object of RootObj a: TRefObj not nil b: TRefObj not nil c: TRefObj diff --git a/tests/converter/tconvert.nim b/tests/converter/tconvert.nim index a37140234..48367a85b 100644 --- a/tests/converter/tconvert.nim +++ b/tests/converter/tconvert.nim @@ -15,6 +15,6 @@ type TFoo = object converter toPtr*(some: var TFoo): ptr TFoo = (addr some) -proc zoot(x: ptr TFoo) = nil +proc zoot(x: ptr TFoo) = discard var x: Tfoo zoot(x) diff --git a/tests/effects/teffects4.nim b/tests/effects/teffects4.nim index fd5dd49e2..d0960126f 100644 --- a/tests/effects/teffects4.nim +++ b/tests/effects/teffects4.nim @@ -12,7 +12,7 @@ type EIO2 = ref object of EIO proc q() {.tags: [FIO].} = - nil + discard proc raiser(): int = writeLine stdout, "arg" diff --git a/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim index f06c4e0be..ac425c7a0 100644 --- a/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim +++ b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim @@ -388,13 +388,13 @@ type cdecl.} ##cp property emulators -template defGetter(otype: typedesc, memberType: typedesc, memberName: expr, procName: expr): stmt {.immediate.} = +template defGetter(otype: typedesc, memberType: typedesc, memberName, procName: untyped) = proc `get procName`*(obj: otype): memberType {.cdecl.} = return obj.memberName -template defSetter(otype: typedesc, memberType: typedesc, memberName: expr, procName: expr): stmt {.immediate.} = +template defSetter(otype: typedesc, memberType: typedesc, memberName, procName: untyped) = proc `set procName`*(obj: otype, value: memberType) {.cdecl.} = obj.memberName = value -template defProp(otype: typedesc, memberType: typedesc, memberName: expr, procName: expr): stmt {.immediate.} = +template defProp(otype: typedesc, memberType: typedesc, memberName, procName: untyped) = defGetter(otype, memberType, memberName, procName) defSetter(otype, memberType, memberName, procName) @@ -908,7 +908,7 @@ proc getShapes*(arb: PArbiter, a, b: var PShape) {.inline.} = #/ A macro shortcut for defining and retrieving the shapes from an arbiter. #define CP_ARBITER_GET_SHAPES(arb, a, b) cpShape *a, *b; cpArbiterGetShapes(arb, &a, &b); -template getShapes*(arb: PArbiter, name1, name2: expr): stmt {.immediate.} = +template getShapes*(arb: PArbiter, name1, name2: untyped) = var name1, name2: PShape getShapes(arb, name1, name2) @@ -923,7 +923,7 @@ template getShapes*(arb: PArbiter, name1, name2: expr): stmt {.immediate.} = #/ A macro shortcut for defining and retrieving the bodies from an arbiter. #define CP_ARBITER_GET_BODIES(arb, a, b) cpBody *a, *b; cpArbiterGetBodies(arb, &a, &b); -template getBodies*(arb: PArbiter, name1, name2: expr): stmt {.immediate.} = +template getBodies*(arb: PArbiter, name1, name2: untyped) = var name1, name2: PBOdy getBodies(arb, name1, name2) @@ -947,11 +947,11 @@ proc getDepth*(arb: PArbiter; i: cint): CpFloat {. cdecl, importc: "cpArbiterGetDepth", dynlib: Lib.} ##Shapes -template defShapeSetter(memberType: typedesc, memberName: expr, procName: expr, activates: bool): stmt {.immediate.} = +template defShapeSetter(memberType: typedesc, memberName: untyped, procName: untyped, activates: bool) = proc `set procName`*(obj: PShape, value: memberType) {.cdecl.} = if activates and obj.body != nil: obj.body.activate() obj.memberName = value -template defShapeProp(memberType: typedesc, memberName: expr, procName: expr, activates: bool): stmt {.immediate.} = +template defShapeProp(memberType: typedesc, memberName: untyped, procName: untyped, activates: bool) = defGetter(PShape, memberType, memberName, procName) defShapeSetter(memberType, memberName, procName, activates) @@ -1272,11 +1272,11 @@ proc activateBodies(constraint: PConstraint) {.inline.} = # cpConstraintActivateBodies(constraint); \ # constraint->member = value; \ # } -template defConstraintSetter(memberType: typedesc, member: expr, name: expr): stmt {.immediate.} = +template defConstraintSetter(memberType: typedesc, member, name: untyped) = proc `set name`*(constraint: PConstraint, value: memberType) {.cdecl.} = activateBodies(constraint) constraint.member = value -template defConstraintProp(memberType: typedesc, member: expr, name: expr): stmt {.immediate.} = +template defConstraintProp(memberType: typedesc, member, name: untyped) = defGetter(PConstraint, memberType, member, name) defConstraintSetter(memberType, member, name) # CP_DefineConstraintStructGetter(cpSpace*, CP_PRIVATE(space), Space) @@ -1306,18 +1306,18 @@ proc getImpulse*(constraint: PConstraint): CpFloat {.inline.} = # cpConstraintActivateBodies(constraint); \ # ((struct *)constraint)->member = value; \ # } -template constraintCheckCast(constraint: PConstraint, ctype: expr): stmt {.immediate.} = +template constraintCheckCast(constraint: PConstraint, ctype: untyped) = assert(constraint.klass == `ctype getClass`(), "Constraint is the wrong class") -template defCGetter(ctype: expr, memberType: typedesc, member: expr, name: expr): stmt {.immediate.} = +template defCGetter(ctype: untyped, memberType: typedesc, member, name: untyped) = proc `get ctype name`*(constraint: PConstraint): memberType {.cdecl.} = constraintCheckCast(constraint, ctype) result = cast[`P ctype`](constraint).member -template defCSetter(ctype: expr, memberType: typedesc, member: expr, name: expr): stmt {.immediate.} = +template defCSetter(ctype: untyped, memberType: typedesc, member, name: untyped) = proc `set ctype name`*(constraint: PConstraint, value: memberType) {.cdecl.} = constraintCheckCast(constraint, ctype) activateBodies(constraint) cast[`P ctype`](constraint).member = value -template defCProp(ctype: expr, memberType: typedesc, member: expr, name: expr): stmt {.immediate.} = +template defCProp(ctype: untyped, memberType: typedesc, member, name: untyped) = defCGetter(ctype, memberType, member, name) defCSetter(ctype, memberType, member, name) diff --git a/tests/manyloc/keineschweine/dependencies/enet/enet.nim b/tests/manyloc/keineschweine/dependencies/enet/enet.nim index 3ea8172d5..07079f2ea 100644 --- a/tests/manyloc/keineschweine/dependencies/enet/enet.nim +++ b/tests/manyloc/keineschweine/dependencies/enet/enet.nim @@ -24,7 +24,7 @@ const ENET_VERSION_MAJOR* = 1 ENET_VERSION_MINOR* = 3 ENET_VERSION_PATCH* = 3 -template ENET_VERSION_CREATE(major, minor, patch: expr): expr = +template ENET_VERSION_CREATE(major, minor, patch: untyped): untyped = (((major) shl 16) or ((minor) shl 8) or (patch)) const @@ -277,22 +277,22 @@ when defined(Linux) or true: dataLength*: csize TENetSocketSet* = Tfd_set ## see if these are different on win32, if not then get rid of these - template ENET_HOST_TO_NET_16*(value: expr): expr = + template ENET_HOST_TO_NET_16*(value: untyped): untyped = (htons(value)) - template ENET_HOST_TO_NET_32*(value: expr): expr = + template ENET_HOST_TO_NET_32*(value: untyped): untyped = (htonl(value)) - template ENET_NET_TO_HOST_16*(value: expr): expr = + template ENET_NET_TO_HOST_16*(value: untyped): untyped = (ntohs(value)) - template ENET_NET_TO_HOST_32*(value: expr): expr = + template ENET_NET_TO_HOST_32*(value: untyped): untyped = (ntohl(value)) - template ENET_SOCKETSET_EMPTY*(sockset: expr): expr = + template ENET_SOCKETSET_EMPTY*(sockset: untyped): untyped = FD_ZERO(addr((sockset))) - template ENET_SOCKETSET_ADD*(sockset, socket: expr): expr = + template ENET_SOCKETSET_ADD*(sockset, socket: untyped): untyped = FD_SET(socket, addr((sockset))) - template ENET_SOCKETSET_REMOVE*(sockset, socket: expr): expr = + template ENET_SOCKETSET_REMOVE*(sockset, socket: untyped): untyped = FD_CLEAR(socket, addr((sockset))) - template ENET_SOCKETSET_CHECK*(sockset, socket: expr): expr = + template ENET_SOCKETSET_CHECK*(sockset, socket: untyped): untyped = FD_ISSET(socket, addr((sockset))) when defined(Windows): @@ -606,7 +606,7 @@ proc protocolCommandSize*(commandNumber: cuchar): csize{. {.pop.} -from hashes import `!$`, `!&`, THash, hash -proc hash*(x: TAddress): THash {.nimcall, noSideEffect.} = +from hashes import `!$`, `!&`, Hash, hash +proc hash*(x: TAddress): Hash {.nimcall, noSideEffect.} = result = !$(hash(x.host.int32) !& hash(x.port.int16)) diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim index 142b190ab..3fb4dc7d9 100644 --- a/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim +++ b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim @@ -1,15 +1,15 @@ import macros, macro_dsl, estreams from strutils import format -template newLenName(): stmt {.immediate.} = +template newLenName() = let lenName {.inject.} = ^("len"& $lenNames) inc(lenNames) -template defPacketImports*(): stmt {.immediate, dirty.} = +template defPacketImports*() {.dirty.} = import macros, macro_dsl, estreams from strutils import format -macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = +macro defPacket*(typeNameN: untyped, typeFields: untyped): untyped = result = newNimNode(nnkStmtList) let typeName = quoted2ident(typeNameN) @@ -60,7 +60,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = let name = typeFields[i][0] dotName = packetID.dot(name) - resName = newIdentNode(!"result").dot(name) + resName = newIdentNode("result").dot(name) case typeFields[i][1].kind of nnkBracketExpr: #ex: paddedstring[32, '\0'], array[range, type] case $typeFields[i][1][0].ident @@ -141,7 +141,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = const emptyFields = {nnkEmpty, nnkNilLit} var objFields = newNimNode(nnkRecList) - for i in 0.. < len(typeFields): + for i in 0 ..< len(typeFields): let fname = typeFields[i][0] constructorParams.add(newNimNode(nnkIdentDefs).und( fname, @@ -200,7 +200,7 @@ proc iddefs*(a: string; b: NimNode): NimNode {.compileTime.} = proc varTy*(a: NimNode): NimNode {.compileTime.} = result = newNimNode(nnkVarTy).und(a) -macro forwardPacket*(typeName: expr, underlyingType: expr): stmt {.immediate.} = +macro forwardPacket*(typeName: untyped, underlyingType: untyped): untyped = var packetID = ^"p" streamID = ^"s" @@ -234,7 +234,7 @@ macro forwardPacket*(typeName: expr, underlyingType: expr): stmt {.immediate.} = echo "unknown type:", repr(underlyingtype) echo(repr(result)) -template forwardPacketT*(typeName: expr; underlyingType: expr): stmt {.dirty, immediate.} = +template forwardPacketT*(typeName: untyped; underlyingType: untyped) {.dirty.} = proc `read typeName`*(buffer: PBuffer): typeName = #discard readData(s, addr result, sizeof(result)) var res: underlyingType diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim b/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim index 86c12fbb0..33d2a7177 100644 --- a/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim +++ b/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim @@ -10,7 +10,7 @@ proc und*(a: NimNode; b: varargs[NimNode]): NimNode {.compileTime.} = proc `^`*(a: string): NimNode {.compileTime.} = ## new ident node - result = newIdentNode(!a) + result = newIdentNode(a) proc `[]`*(a, b: NimNode): NimNode {.compileTime.} = ## new bracket expression: node[node] not to be confused with node[indx] result = newNimNode(nnkBracketExpr).und(a, b) @@ -34,7 +34,7 @@ proc emptyNode*(): NimNode {.compileTime.} = proc dot*(left, right: NimNode): NimNode {.compileTime.} = result = newNimNode(nnkDotExpr).und(left, right) proc prefix*(a: string, b: NimNode): NimNode {.compileTime.} = - result = newNimNode(nnkPrefix).und(newIdentNode(!a), b) + result = newNimNode(nnkPrefix).und(newIdentNode(a), b) proc quoted2ident*(a: NimNode): NimNode {.compileTime.} = if a.kind != nnkAccQuoted: @@ -45,13 +45,13 @@ proc quoted2ident*(a: NimNode): NimNode {.compileTime.} = result = ^pname -macro `?`(a: expr): expr = +macro `?`(a: untyped): untyped = ## Character literal ?A #=> 'A' result = ($a[1].ident)[0].lit ## echo(?F,?a,?t,?t,?y) when isMainModule: - macro foo(x: stmt): stmt = + macro foo(x: untyped) = result = newNimNode(nnkStmtList) result.add(newNimNode(nnkCall).und(!!"echo", "Hello thar".lit)) result.add(newCall("echo", lit("3 * 45 = "), (3.lit.infix("*", 45.lit)))) diff --git a/tests/manyloc/keineschweine/lib/estreams.nim b/tests/manyloc/keineschweine/lib/estreams.nim index bdf9b2bf0..00a55c626 100644 --- a/tests/manyloc/keineschweine/lib/estreams.nim +++ b/tests/manyloc/keineschweine/lib/estreams.nim @@ -78,7 +78,7 @@ proc write*(buffer: PBuffer; val: var string) = setLen buffer.data, buffer.pos + length.int copyMem(addr buffer.data[buffer.pos], addr val[0], length.int) inc buffer.pos, length.int -proc write*[T: TNumber|bool|char|byte](buffer: PBuffer; val: T) = +proc write*[T: SomeNumber|bool|char|byte](buffer: PBuffer; val: T) = var v: T shallowCopy v, val writeBE buffer, v diff --git a/tests/manyloc/keineschweine/lib/input_helpers.nim b/tests/manyloc/keineschweine/lib/input_helpers.nim index 1953cb58c..ff1286c8d 100644 --- a/tests/manyloc/keineschweine/lib/input_helpers.nim +++ b/tests/manyloc/keineschweine/lib/input_helpers.nim @@ -5,8 +5,8 @@ type TInputFinishedProc* = proc() TKeyCallback = proc() PKeyClient* = ref object - onKeyDown: TTable[int32, TKeyCallback] - onKeyUp: TTable[int32, TKeyCallback] + onKeyDown: Table[int32, TKeyCallback] + onKeyUp: Table[int32, TKeyCallback] name: string PTextInput* = ref object text*: string @@ -134,5 +134,5 @@ iterator pollEvents*(window: PRenderWindow): PEvent = of EvtMouseButtonReleased: addButtonEvent(event.mouseButton.button, up) of EvtTextEntered: recordText(activeInput, event.text) of EvtMouseMoved: setMousePos(event.mouseMove.x, event.mouseMove.y) - else: nil + else: discard yield(addr event) diff --git a/tests/manyloc/keineschweine/lib/sg_assets.nim b/tests/manyloc/keineschweine/lib/sg_assets.nim index c6540a428..1e8a99c83 100644 --- a/tests/manyloc/keineschweine/lib/sg_assets.nim +++ b/tests/manyloc/keineschweine/lib/sg_assets.nim @@ -59,7 +59,7 @@ type of Projectile: bullet*: PBulletRecord else: - nil + discard PBulletRecord* = ref TBulletRecord TBulletRecord* = object id*: int16 @@ -115,10 +115,10 @@ var cfg: PZoneSettings SpriteSheets* = initTable[string, PSpriteSheet](64) SoundCache * = initTable[string, PSoundRecord](64) - nameToVehID*: TTable[string, int] - nameToItemID*: TTable[string, int] - nameToObjID*: TTable[string, int] - nameToBulletID*: TTable[string, int] + nameToVehID*: Table[string, int] + nameToItemID*: Table[string, int] + nameToObjID*: Table[string, int] + nameToBulletID*: Table[string, int] activeState = Lobby proc newSprite*(filename: string; errors: var seq[string]): PSpriteSheet @@ -126,7 +126,7 @@ proc load*(ss: PSpriteSheet): bool {.discardable.} proc newSound*(filename: string; errors: var seq[string]): PSoundRecord proc load*(s: PSoundRecord): bool {.discardable.} -proc validateSettings*(settings: PJsonNode; errors: var seq[string]): bool +proc validateSettings*(settings: JsonNode; errors: var seq[string]): bool proc loadSettings*(rawJson: string, errors: var seq[string]): bool proc loadSettingsFromFile*(filename: string, errors: var seq[string]): bool @@ -135,17 +135,17 @@ proc fetchItm*(itm: string): PItemRecord proc fetchObj*(name: string): PObjectRecord proc fetchBullet(name: string): PBulletRecord -proc importLevel(data: PJsonNode; errors: var seq[string]): PLevelSettings -proc importVeh(data: PJsonNode; errors: var seq[string]): PVehicleRecord -proc importObject(data: PJsonNode; errors: var seq[string]): PObjectRecord -proc importItem(data: PJsonNode; errors: var seq[string]): PItemRecord -proc importPhys(data: PJsonNode): TPhysicsRecord -proc importAnim(data: PJsonNode; errors: var seq[string]): PAnimationRecord -proc importHandling(data: PJsonNode): THandlingRecord -proc importBullet(data: PJsonNode; errors: var seq[string]): PBulletRecord -proc importSoul(data: PJsonNode): TSoulRecord -proc importExplosion(data: PJsonNode; errors: var seq[string]): TExplosionRecord -proc importSound*(data: PJsonNode; errors: var seq[string]; fieldName: string = nil): PSoundRecord +proc importLevel(data: JsonNode; errors: var seq[string]): PLevelSettings +proc importVeh(data: JsonNode; errors: var seq[string]): PVehicleRecord +proc importObject(data: JsonNode; errors: var seq[string]): PObjectRecord +proc importItem(data: JsonNode; errors: var seq[string]): PItemRecord +proc importPhys(data: JsonNode): TPhysicsRecord +proc importAnim(data: JsonNode; errors: var seq[string]): PAnimationRecord +proc importHandling(data: JsonNode): THandlingRecord +proc importBullet(data: JsonNode; errors: var seq[string]): PBulletRecord +proc importSoul(data: JsonNode): TSoulRecord +proc importExplosion(data: JsonNode; errors: var seq[string]): TExplosionRecord +proc importSound*(data: JsonNode; errors: var seq[string]; fieldName: string = nil): PSoundRecord ## this is the only pipe between lobby and main.nim proc getActiveState*(): TGameState = @@ -203,7 +203,7 @@ iterator playableVehicles*(): PVehicleRecord = if v.playable: yield v -template allAssets*(body: stmt) {.dirty.}= +template allAssets*(body: untyped) {.dirty.}= block: var assetType = FGraphics for file, asset in pairs(SpriteSheets): @@ -212,7 +212,7 @@ template allAssets*(body: stmt) {.dirty.}= for file, asset in pairs(SoundCache): body -template cacheImpl(procName, cacheName, resultType: expr; body: stmt) {.dirty, immediate.} = +template cacheImpl(procName, cacheName, resultType, body: untyped) {.dirty.} = proc procName*(filename: string; errors: var seq[string]): resulttype = if hasKey(cacheName, filename): return cacheName[filename] @@ -220,7 +220,7 @@ template cacheImpl(procName, cacheName, resultType: expr; body: stmt) {.dirty, i body cacheName[filename] = result -template checkFile(path: expr): stmt {.dirty, immediate.} = +template checkFile(path: untyped) {.dirty.} = if not existsFile(path): errors.add("File missing: "& path) @@ -243,7 +243,7 @@ proc expandPath*(assetType: TAssetType; fileName: string): string = case assetType of FGraphics: result.add "gfx/" of FSound: result.add "sfx/" - else: nil + else: discard result.add fileName proc expandPath*(fc: ScFileChallenge): string {.inline.} = result = expandPath(fc.assetType, fc.file) @@ -280,10 +280,10 @@ else: if not s.soundBuf.isNil: result = true -template addError(e: expr): stmt {.immediate.} = +template addError(e: untyped) = errors.add(e) result = false -proc validateSettings*(settings: PJsonNode, errors: var seq[string]): bool = +proc validateSettings*(settings: JsonNode, errors: var seq[string]): bool = result = true if settings.kind != JObject: addError("Settings root must be an object") @@ -328,10 +328,10 @@ proc loadSettingsFromFile*(filename: string, errors: var seq[string]): bool = result = loadSettings(readFile(filename), errors) proc loadSettings*(rawJson: string, errors: var seq[string]): bool = - var settings: PJsonNode + var settings: JsonNode try: settings = parseJson(rawJson) - except EJsonParsingError: + except JsonParsingError: errors.add("JSON parsing error: "& getCurrentExceptionMsg()) return except: @@ -407,21 +407,21 @@ proc fetchObj*(name: string): PObjectRecord = proc fetchBullet(name: string): PBulletRecord = return cfg.bullets[nameToBulletID[name]] -proc getField(node: PJsonNode, field: string, target: var float) = +proc getField(node: JsonNode, field: string, target: var float) = if not node.hasKey(field): return if node[field].kind == JFloat: target = node[field].fnum elif node[field].kind == JInt: target = node[field].num.float -proc getField(node: PJsonNode, field: string, target: var int) = +proc getField(node: JsonNode, field: string, target: var int) = if not node.hasKey(field): return if node[field].kind == JInt: target = node[field].num.int elif node[field].kind == JFloat: target = node[field].fnum.int -proc getField(node: PJsonNode; field: string; target: var bool) = +proc getField(node: JsonNode; field: string; target: var bool) = if not node.hasKey(field): return case node[field].kind @@ -431,19 +431,19 @@ proc getField(node: PJsonNode; field: string; target: var bool) = target = (node[field].num != 0) of JFloat: target = (node[field].fnum != 0.0) - else: nil + else: discard -template checkKey(node: expr; key: string): stmt = +template checkKey(node: untyped; key: string) = if not hasKey(node, key): return -proc importTrail(data: PJsonNode; errors: var seq[string]): TTrailRecord = +proc importTrail(data: JsonNode; errors: var seq[string]): TTrailRecord = checkKey(data, "trail") result.anim = importAnim(data["trail"], errors) result.timer = 1000.0 getField(data["trail"], "timer", result.timer) result.timer /= 1000.0 -proc importLevel(data: PJsonNode; errors: var seq[string]): PLevelSettings = +proc importLevel(data: JsonNode; errors: var seq[string]): PLevelSettings = new(result) result.size = vec2i(5000, 5000) result.starfield = @[] @@ -456,7 +456,7 @@ proc importLevel(data: PJsonNode; errors: var seq[string]): PLevelSettings = if level.hasKey("starfield"): for star in level["starfield"].items: result.starfield.add(newSprite(star.str, errors)) -proc importPhys(data: PJsonNode): TPhysicsRecord = +proc importPhys(data: JsonNode): TPhysicsRecord = result.radius = 20.0 result.mass = 10.0 @@ -466,7 +466,7 @@ proc importPhys(data: PJsonNode): TPhysicsRecord = phys.getField("mass", result.mass) when not defined(NoChipmunk): result.moment = momentForCircle(result.mass, 0.0, result.radius, VectorZero) * MomentMult -proc importHandling(data: PJsonNode): THandlingRecord = +proc importHandling(data: JsonNode): THandlingRecord = result.thrust = 45.0 result.topSpeed = 100.0 #unused result.reverse = 30.0 @@ -483,7 +483,7 @@ proc importHandling(data: PJsonNode): THandlingRecord = hand.getField("reverse", result.reverse) hand.getField("strafe", result.strafe) hand.getField("rotation", result.rotation) -proc importAnim(data: PJsonNode, errors: var seq[string]): PAnimationRecord = +proc importAnim(data: JsonNode, errors: var seq[string]): PAnimationRecord = new(result) result.angle = 0.0 result.delay = 1000.0 @@ -502,26 +502,26 @@ proc importAnim(data: PJsonNode, errors: var seq[string]): PAnimationRecord = result.angle = radians(result.angle) ## comes in as degrees result.delay /= 1000 ## delay comes in as milliseconds -proc importSoul(data: PJsonNode): TSoulRecord = +proc importSoul(data: JsonNode): TSoulRecord = result.energy = 10000 result.health = 1 checkKey(data, "soul") let soul = data["soul"] soul.getField("energy", result.energy) soul.getField("health", result.health) -proc importExplosion(data: PJsonNode; errors: var seq[string]): TExplosionRecord = +proc importExplosion(data: JsonNode; errors: var seq[string]): TExplosionRecord = checkKey(data, "explode") let expl = data["explode"] result.anim = importAnim(expl, errors) result.sound = importSound(expl, errors, "sound") -proc importSound*(data: PJsonNode; errors: var seq[string]; fieldName: string = nil): PSoundRecord = +proc importSound*(data: JsonNode; errors: var seq[string]; fieldName: string = nil): PSoundRecord = if data.kind == JObject: checkKey(data, fieldName) result = newSound(data[fieldName].str, errors) elif data.kind == JString: result = newSound(data.str, errors) -proc importVeh(data: PJsonNode; errors: var seq[string]): PVehicleRecord = +proc importVeh(data: JsonNode; errors: var seq[string]): PVehicleRecord = new(result) result.playable = false if data.kind != JArray or data.len != 2 or @@ -538,7 +538,7 @@ proc importVeh(data: PJsonNode; errors: var seq[string]): PVehicleRecord = vehdata.getField("playable", result.playable) if result.anim.spriteSheet.isNil and result.playable: result.playable = false -proc importObject(data: PJsonNode; errors: var seq[string]): PObjectRecord = +proc importObject(data: JsonNode; errors: var seq[string]): PObjectRecord = new(result) if data.kind != JArray or data.len != 2: result.name = "(broken)" @@ -546,7 +546,7 @@ proc importObject(data: PJsonNode; errors: var seq[string]): PObjectRecord = result.name = data[0].str result.anim = importAnim(data[1], errors) result.physics = importPhys(data[1]) -proc importItem(data: PJsonNode; errors: var seq[string]): PItemRecord = +proc importItem(data: JsonNode; errors: var seq[string]): PItemRecord = new(result) if data.kind != JArray or data.len != 3: result.name = "(broken)" @@ -576,15 +576,15 @@ proc importItem(data: PJsonNode; errors: var seq[string]): PItemRecord = of "ammo": result.kind = Ammo of "utility": - nil + discard else: errors.add "Invalid item type \""&data[1].str&"\" for item "&result.name -proc importBullet(data: PJsonNode; errors: var seq[string]): PBulletRecord = +proc importBullet(data: JsonNode; errors: var seq[string]): PBulletRecord = new(result) result.id = -1 - var bdata: PJsonNode + var bdata: JsonNode if data.kind == JArray: result.name = data[0].str bdata = data[1] diff --git a/tests/manyloc/keineschweine/lib/sg_packets.nim b/tests/manyloc/keineschweine/lib/sg_packets.nim index d84bf72fc..f3a0e8925 100644 --- a/tests/manyloc/keineschweine/lib/sg_packets.nim +++ b/tests/manyloc/keineschweine/lib/sg_packets.nim @@ -4,14 +4,14 @@ defPacketImports() type PacketID* = char -template idpacket(pktName, id, s2c, c2s: expr): stmt {.immediate, dirty.} = +template idpacket(pktName, id, s2c, c2s: untyped) {.dirty.} = let `H pktName`* {.inject.} = id defPacket(`Sc pktName`, s2c) defPacket(`Cs pktName`, c2s) forwardPacketT(uint8, int8) forwardPacketT(uint16, int16) -forwardPacketT(TPort, int16) +forwardPacketT(Port, int16) idPacket(Login, 'a', tuple[id: int32; alias: string; sessionKey: string], @@ -22,7 +22,7 @@ defPacket(CsZoneJoinReq, tuple[session: ScLogin]) defPacket(ScZoneRecord, tuple[ name: string = "", desc: string = "", - ip: string = "", port: TPort = 0.Tport]) + ip: string = "", port: Port = 0.Port]) idPacket(ZoneList, 'z', tuple[network: string = "", zones: seq[ScZoneRecord]], tuple[time: string]) diff --git a/tests/metatype/tbindtypedesc.nim b/tests/metatype/tbindtypedesc.nim index b287aad01..039acfbe9 100644 --- a/tests/metatype/tbindtypedesc.nim +++ b/tests/metatype/tbindtypedesc.nim @@ -46,7 +46,7 @@ type type1 = typedesc type2 = typedesc -proc typePairs(A, B: type1; C, D: type2) = nil +proc typePairs(A, B: type1; C, D: type2) = discard accept typePairs(int, int, TFoo, TFOO) accept typePairs(TBAR, TBar, TBAR, TBAR) @@ -55,7 +55,7 @@ accept typePairs(int, int, string, string) reject typePairs(TBAR, TBar, TBar, TFoo) reject typePairs(string, int, TBAR, TBAR) -proc typePairs2[T: typedesc, U: typedesc](A, B: T; C, D: U) = nil +proc typePairs2[T: typedesc, U: typedesc](A, B: T; C, D: U) = discard accept typePairs2(int, int, TFoo, TFOO) accept typePairs2(TBAR, TBar, TBAR, TBAR) @@ -71,12 +71,12 @@ proc dontBind(a: typedesc, b: typedesc) = accept dontBind(int, float) accept dontBind(TFoo, TFoo) -proc dontBind2(a, b: typedesc) = nil +proc dontBind2(a, b: typedesc) = discard accept dontBind2(int, float) accept dontBind2(TBar, int) -proc bindArg(T: typedesc, U: typedesc, a, b: T, c, d: U) = nil +proc bindArg(T: typedesc, U: typedesc, a, b: T, c, d: U) = discard accept bindArg(int, string, 10, 20, "test", "nest") accept bindArg(int, int, 10, 20, 30, 40) diff --git a/tests/notnil/tnotnil2.nim b/tests/notnil/tnotnil2.nim index 6ab7bf951..6cd08de73 100644 --- a/tests/notnil/tnotnil2.nim +++ b/tests/notnil/tnotnil2.nim @@ -11,7 +11,7 @@ type x, y: int proc q(x: pointer not nil) = - nil + discard proc p() = var x: pointer diff --git a/tests/objvariant/tcheckedfield1.nim b/tests/objvariant/tcheckedfield1.nim index 56d784a2b..a7f232c5b 100644 --- a/tests/objvariant/tcheckedfield1.nim +++ b/tests/objvariant/tcheckedfield1.nim @@ -6,7 +6,7 @@ discard """ import strutils {.warning[ProveField]: on.} - +{.experimental: "notnil".} type TNodeKind = enum nkBinary, nkTernary, nkStr diff --git a/tests/overload/tissue966.nim b/tests/overload/tissue966.nim index c5b28e217..d0a723875 100644 --- a/tests/overload/tissue966.nim +++ b/tests/overload/tissue966.nim @@ -5,7 +5,7 @@ discard """ type PTest = ref object -proc test(x: PTest, y: int) = nil +proc test(x: PTest, y: int) = discard var buf: PTest buf.test() diff --git a/tests/proc/tprocredef.nim b/tests/proc/tprocredef.nim index 86ed92b62..4ec771510 100644 --- a/tests/proc/tprocredef.nim +++ b/tests/proc/tprocredef.nim @@ -4,6 +4,6 @@ discard """ errormsg: "redefinition of \'foo\'" """ -proc foo(a: int, b: string) = nil -proc foo(a: int, b: string) = nil +proc foo(a: int, b: string) = discard +proc foo(a: int, b: string) = discard diff --git a/tests/range/tsubrange.nim b/tests/range/tsubrange.nim index 6f88c5a22..914e7c6e7 100644 --- a/tests/range/tsubrange.nim +++ b/tests/range/tsubrange.nim @@ -7,7 +7,7 @@ type TRange = range[0..40] proc p(r: TRange) = - nil + discard var r: TRange |