diff --git a/stew/arrayops.nim b/stew/arrayops.nim index 3060a12..4cc0007 100644 --- a/stew/arrayops.nim +++ b/stew/arrayops.nim @@ -1,13 +1,10 @@ -# Copyright (c) 2020-2022 Status Research & Development GmbH +# Copyright (c) 2020-2023 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} ## Operations on array and openArray diff --git a/stew/assign2.nim b/stew/assign2.nim index 5e34cf9..5b28326 100644 --- a/stew/assign2.nim +++ b/stew/assign2.nim @@ -2,10 +2,7 @@ import std/typetraits, ./shims/macros -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} func assign*[T](tgt: var seq[T], src: openArray[T]) {.gcsafe.} func assign*[T](tgt: var openArray[T], src: openArray[T]) {.gcsafe.} diff --git a/stew/base10.nim b/stew/base10.nim index 19c2456..f335a8d 100644 --- a/stew/base10.nim +++ b/stew/base10.nim @@ -1,4 +1,4 @@ -## Copyright (c) 2021-2022 Status Research & Development GmbH +## Copyright (c) 2021-2023 Status Research & Development GmbH ## Licensed under either of ## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) ## * MIT license ([LICENSE-MIT](LICENSE-MIT)) @@ -13,10 +13,7 @@ import results export results -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} type Base10* = object diff --git a/stew/bitseqs.nim b/stew/bitseqs.nim index 0907ee1..1ed7d6d 100644 --- a/stew/bitseqs.nim +++ b/stew/bitseqs.nim @@ -1,7 +1,4 @@ -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} import bitops2, ptrops diff --git a/stew/byteutils.nim b/stew/byteutils.nim index a6418a0..45af334 100644 --- a/stew/byteutils.nim +++ b/stew/byteutils.nim @@ -1,5 +1,5 @@ # byteutils -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). @@ -16,12 +16,8 @@ import # backwards compat export arrayops.`&`, arrayops.initArrayWith, arrayops.`[]=` -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} - {.pragma: hexRaises, raises: [Defect, ValueError].} -else: - {.push raises: [].} - {.pragma: hexRaises, raises: [ValueError].} +{.push raises: [].} +{.pragma: hexRaises, raises: [ValueError].} ######################################################################################################## ##################################### Hex utilities ################################################ diff --git a/stew/ctops.nim b/stew/ctops.nim index c9bf43b..6b751a7 100644 --- a/stew/ctops.nim +++ b/stew/ctops.nim @@ -1,4 +1,4 @@ -## Copyright (c) 2020 Status Research & Development GmbH +## Copyright (c) 2020-2023 Status Research & Development GmbH ## Licensed under either of ## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) ## * MIT license ([LICENSE-MIT](LICENSE-MIT)) @@ -19,10 +19,7 @@ elif sizeof(int) == 4: type AnyItem* = byte|char|int8|uint16|int16|uint32|int32|uint|int -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} proc isEqual*[A: AnyItem, B: AnyItem](c: typedesc[CT], a: openArray[A], b: openArray[B]): bool = diff --git a/stew/enums.nim b/stew/enums.nim index 1606a19..c8cb88c 100644 --- a/stew/enums.nim +++ b/stew/enums.nim @@ -33,10 +33,7 @@ macro enumStyle*(t: typedesc[enum]): untyped = of nnkEmpty: continue of nnkIdent: - when (NimMajor, NimMinor) < (1, 4): # `nnkSym` in Nim 1.2 - style.setMode(EnumStyle.Numeric, typ) - else: - error("Unexpected enum node for deserialization: " & $f.kind) + error("Unexpected enum node for deserialization: " & $f.kind) of nnkSym: style.setMode(EnumStyle.Numeric, typ) of nnkEnumFieldDef: diff --git a/stew/interval_set.nim b/stew/interval_set.nim index aeb267f..298165c 100644 --- a/stew/interval_set.nim +++ b/stew/interval_set.nim @@ -1,6 +1,6 @@ # Nimbus - Types, data structures and shared utilities used in network sync # -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -111,10 +111,7 @@ import "."/[results, sorted_set] -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect, CatchableError].} -else: - {.push raises: [].} +{.push raises: [].} export `isRed=`, diff --git a/stew/io2.nim b/stew/io2.nim index 14c5b79..be5be90 100644 --- a/stew/io2.nim +++ b/stew/io2.nim @@ -1,4 +1,4 @@ -## Copyright (c) 2020-2022 Status Research & Development GmbH +## Copyright (c) 2020-2023 Status Research & Development GmbH ## Licensed under either of ## * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) ## * MIT license ([LICENSE-MIT](LICENSE-MIT)) @@ -10,10 +10,7 @@ ## not use exceptions and using Result[T] for error handling. ## -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} import algorithm import results diff --git a/stew/keyed_queue.nim b/stew/keyed_queue.nim index 0fd7617..3afb750 100644 --- a/stew/keyed_queue.nim +++ b/stew/keyed_queue.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -29,10 +29,7 @@ import export results -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} type KeyedQueueItem*[K,V] = object ##\ diff --git a/stew/keyed_queue/kq_debug.nim b/stew/keyed_queue/kq_debug.nim index b6de15e..353838e 100644 --- a/stew/keyed_queue/kq_debug.nim +++ b/stew/keyed_queue/kq_debug.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -31,10 +31,7 @@ type kQVfyPrvNxtExpected kQVfyFirstExpected -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} # ------------------------------------------------------------------------------ # Public functions, debugging diff --git a/stew/ranges/stackarrays.nim b/stew/ranges/stackarrays.nim index 56d4422..225bc8c 100644 --- a/stew/ranges/stackarrays.nim +++ b/stew/ranges/stackarrays.nim @@ -37,9 +37,6 @@ ## be reasonable for short-lived allocations. ## -when (NimMajor, NimMinor) < (1, 4): - import ../shims/stddefects - type StackArray*[T] = object bufferLen: int32 diff --git a/stew/shims/stddefects.nim b/stew/shims/stddefects.nim index 46a3440..6cdc072 100644 --- a/stew/shims/stddefects.nim +++ b/stew/shims/stddefects.nim @@ -1,25 +1 @@ -when (NimMajor, NimMinor) < (1, 4): - type - AccessViolationDefect* = AccessViolationError - ArithmeticDefect* = ArithmeticError - AssertionDefect* = AssertionError - DeadThreadDefect* = DeadThreadError - DivByZeroDefect* = DivByZeroError - FieldDefect* = FieldError - FloatDivByZeroDefect* = FloatDivByZeroError - FloatInexactDefect* = FloatInexactError - FloatInvalidOpDefect* = FloatInvalidOpError - FloatOverflowDefect* = FloatOverflowError - FloatUnderflowDefect* = FloatUnderflowError - FloatingPointDefect* = FloatingPointError - IndexDefect* = IndexError - NilAccessDefect* = NilAccessError - ObjectAssignmentDefect* = ObjectAssignmentError - ObjectConversionDefect* = ObjectConversionError - OutOfMemDefect* = OutOfMemError - OverflowDefect* = OverflowError - RangeDefect* = RangeError - ReraiseDefect* = ReraiseError - StackOverflowDefect* = StackOverflowError -else: - {.used.} +{.deprecated: "Nim 1.4 and newer support FooDefect directly".} diff --git a/stew/sorted_set.nim b/stew/sorted_set.nim index 616bf8e..3b6d197 100644 --- a/stew/sorted_set.nim +++ b/stew/sorted_set.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -87,10 +87,7 @@ type ## returned from functions. RbResult[SortedSetItemRef[K,V]] -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect,CatchableError].} -else: - {.push raises: [].} +{.push raises: [].} # ------------------------------------------------------------------------------ # Private helpers diff --git a/stew/sorted_set/rbtree_delete.nim b/stew/sorted_set/rbtree_delete.nim index 9b05123..a2d8b09 100644 --- a/stew/sorted_set/rbtree_delete.nim +++ b/stew/sorted_set/rbtree_delete.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -13,10 +13,7 @@ import ./rbtree_rotate, ../results -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} # ------------------------------------------------------------------------------ # Public diff --git a/stew/sorted_set/rbtree_desc.nim b/stew/sorted_set/rbtree_desc.nim index 620e414..686e93a 100644 --- a/stew/sorted_set/rbtree_desc.nim +++ b/stew/sorted_set/rbtree_desc.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -170,10 +170,7 @@ type start*: bool ## `true` after a rewind operation stop*: bool ## End of traversal -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} # ------------------------------------------------------------------------------ # Public functions, constructor diff --git a/stew/sorted_set/rbtree_find.nim b/stew/sorted_set/rbtree_find.nim index 62a39a7..1274f0f 100644 --- a/stew/sorted_set/rbtree_find.nim +++ b/stew/sorted_set/rbtree_find.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -12,10 +12,7 @@ import ./rbtree_desc, ../results -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} # ----------------------------------------------------------------------- ------ # Public diff --git a/stew/sorted_set/rbtree_flush.nim b/stew/sorted_set/rbtree_flush.nim index f823b87..0b84aa8 100644 --- a/stew/sorted_set/rbtree_flush.nim +++ b/stew/sorted_set/rbtree_flush.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -14,10 +14,7 @@ import type RbTreeFlushDel*[C] = proc(c: var C) {.gcsafe.} -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} # ----------------------------------------------------------------------- ------ # Private diff --git a/stew/sorted_set/rbtree_insert.nim b/stew/sorted_set/rbtree_insert.nim index 96d55f7..73b7998 100644 --- a/stew/sorted_set/rbtree_insert.nim +++ b/stew/sorted_set/rbtree_insert.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -13,10 +13,7 @@ import ./rbtree_rotate, ../results -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} # ----------------------------------------------------------------------- ------ # Private functions diff --git a/stew/sorted_set/rbtree_reset.nim b/stew/sorted_set/rbtree_reset.nim index 7d81acd..05a6864 100644 --- a/stew/sorted_set/rbtree_reset.nim +++ b/stew/sorted_set/rbtree_reset.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -13,10 +13,7 @@ import ./rbtree_flush, ./rbtree_walk -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} # ----------------------------------------------------------------------- ------ # Public diff --git a/stew/sorted_set/rbtree_rotate.nim b/stew/sorted_set/rbtree_rotate.nim index 1910edb..8c5964a 100644 --- a/stew/sorted_set/rbtree_rotate.nim +++ b/stew/sorted_set/rbtree_rotate.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -11,10 +11,7 @@ import ./rbtree_desc -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} proc rbTreeRotateSingle*[C](node: RbNodeRef[C]; dir: RbDir): RbNodeRef[C] = ## Perform a single red-black tree rotation in the specified direction. diff --git a/stew/sorted_set/rbtree_verify.nim b/stew/sorted_set/rbtree_verify.nim index 69ca358..4009ded 100644 --- a/stew/sorted_set/rbtree_verify.nim +++ b/stew/sorted_set/rbtree_verify.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -18,18 +18,10 @@ type ## for the equivalent of `a < b` proc(a, b: C): bool {.gcsafe.} -when (NimMajor, NimMinor) < (1, 4): - type - RbPrnFn* = ##\ - ## Handle error message - proc(code: RbInfo; ctxInfo: string) - {.gcsafe, raises: [Defect,CatchableError].} -else: - type - RbPrnFn* = ##\ - ## Handle error message - proc(code: RbInfo; ctxInfo: string) - {.gcsafe, raises: [].} + RbPrnFn* = ##\ + ## Handle error message + proc(code: RbInfo; ctxInfo: string) + {.gcsafe, raises: [].} type RbDdebug[C,K] = object @@ -42,10 +34,7 @@ type pr: RbPrnFn msg: string ## collect data -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect, CatchableError].} -else: - {.push raises: [].} +{.push raises: [].} # ----------------------------------------------------------------------- ------ # Private diff --git a/stew/sorted_set/rbtree_walk.nim b/stew/sorted_set/rbtree_walk.nim index bcd9b0c..754c18d 100644 --- a/stew/sorted_set/rbtree_walk.nim +++ b/stew/sorted_set/rbtree_walk.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2022 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) @@ -13,10 +13,7 @@ import ./rbtree_desc, ../results -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} # ----------------------------------------------------------------------- ------ # Priv diff --git a/tests/ranges/tstackarrays.nim b/tests/ranges/tstackarrays.nim index ff75a94..76da7d8 100644 --- a/tests/ranges/tstackarrays.nim +++ b/tests/ranges/tstackarrays.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2022 Status Research & Development GmbH +# Copyright (c) 2019-2023 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license: http://opensource.org/licenses/MIT # * Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 @@ -11,9 +11,6 @@ import ../../stew/ptrops, ../../stew/ranges/[stackarrays] -when (NimMajor, NimMinor) < (1, 4): - import ../../stew/shims/stddefects - suite "Stack arrays": test "Basic operations work as expected": var arr = allocStackArray(int, 10) diff --git a/tests/test_ctops.nim b/tests/test_ctops.nim index 1bd402c..51c86d8 100644 --- a/tests/test_ctops.nim +++ b/tests/test_ctops.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2022 Status Research & Development GmbH +# Copyright (c) 2020-2023 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license: http://opensource.org/licenses/MIT # * Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 @@ -9,10 +9,7 @@ import unittest2 import ../stew/ctops -when (NimMajor, NimMinor) < (1, 6): - type DefectEx = AssertionError -else: - type DefectEx = AssertionDefect +type DefectEx = AssertionDefect suite "Constant-time operations test suite": test "isEqual() test": diff --git a/tests/test_keyed_queue.nim b/tests/test_keyed_queue.nim index f51293b..294646a 100644 --- a/tests/test_keyed_queue.nim +++ b/tests/test_keyed_queue.nim @@ -533,10 +533,7 @@ suite "KeyedQueue: Data queue as LRU cache": s0 = sq key = sq[5].toKey - when (NimMajor, NimMinor) >= (1, 6): - sq.delete(5..5) # delete index 5 in sequence - else: - sq.delete(5, 5) # delete index 5 in sequence + sq.delete(5..5) # delete index 5 in sequence noisy.say &"sq: {s0} {sq}"