From ecaccafa6c18e0b92cd5f75d3363d61c0866dec9 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Wed, 11 Oct 2023 23:18:54 +0800 Subject: [PATCH] =?UTF-8?q?fixes=20#22790;=20use=20cast=20suppress=20AnyEn?= =?UTF-8?q?umConv=20warnings=20for=20enums=20withou=E2=80=A6=20(#22813)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …t holes fixes #22790 --- compiler/condsyms.nim | 2 ++ lib/system/iterators_1.nim | 17 +++++++++++++---- tests/parallel/tuseafterdef.nim | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index 81081fd93b..520545a815 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 be61fd62ce..d00e3f823f 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 e73f1b7946..64f835a1bc 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