diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-10-11 23:18:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-11 17:18:54 +0200 |
commit | ecaccafa6c18e0b92cd5f75d3363d61c0866dec9 (patch) | |
tree | a7684c56cff19f6ae816dd67aace2c859e5f3081 | |
parent | 9d7acd001f268e2b9dab9228ca5e22bf75028704 (diff) | |
download | Nim-ecaccafa6c18e0b92cd5f75d3363d61c0866dec9.tar.gz |
fixes #22790; use cast suppress AnyEnumConv warnings for enums withou… (#22813)
…t holes fixes #22790
-rw-r--r-- | compiler/condsyms.nim | 2 | ||||
-rw-r--r-- | lib/system/iterators_1.nim | 17 | ||||
-rw-r--r-- | tests/parallel/tuseafterdef.nim | 1 |
3 files changed, 16 insertions, 4 deletions
diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index 81081fd93..520545a81 100644 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -160,3 +160,5 @@ proc initDefines*(symbols: StringTableRef) = defineSymbol("nimUseStrictDefs") defineSymbol("nimHasNolineTooLong") + + defineSymbol("nimHasCastExtendedVm") diff --git a/lib/system/iterators_1.nim b/lib/system/iterators_1.nim index be61fd62c..d00e3f823 100644 --- a/lib/system/iterators_1.nim +++ b/lib/system/iterators_1.nim @@ -16,7 +16,7 @@ iterator countdown*[T](a, b: T, step: Positive = 1): T {.inline.} = let x = collect(newSeq): for i in countdown(7, 3): i - + assert x == @[7, 6, 5, 4, 3] let y = collect(newseq): @@ -32,7 +32,10 @@ iterator countdown*[T](a, b: T, step: Positive = 1): T {.inline.} = elif T is IntLikeForCount and T is Ordinal: var res = int(a) while res >= int(b): - yield T(res) + when defined(nimHasCastExtendedVm): + yield cast[T](res) + else: + yield T(res) dec(res, step) else: var res = a @@ -64,7 +67,10 @@ iterator countup*[T](a, b: T, step: Positive = 1): T {.inline.} = when T is IntLikeForCount and T is Ordinal: var res = int(a) while res <= int(b): - yield T(res) + when defined(nimHasCastExtendedVm): + yield cast[T](res) + else: + yield T(res) inc(res, step) else: var res = a @@ -89,7 +95,10 @@ iterator `..`*[T](a, b: T): T {.inline.} = when T is IntLikeForCount and T is Ordinal: var res = int(a) while res <= int(b): - yield T(res) + when defined(nimHasCastExtendedVm): + yield cast[T](res) + else: + yield T(res) inc(res) else: var res = a diff --git a/tests/parallel/tuseafterdef.nim b/tests/parallel/tuseafterdef.nim index e73f1b794..64f835a1b 100644 --- a/tests/parallel/tuseafterdef.nim +++ b/tests/parallel/tuseafterdef.nim @@ -1,5 +1,6 @@ discard """ matrix: "--mm:refc" + disabled: true errormsg: "(k)..(k) not disjoint from (k)..(k)" line: 24 action: compile |