diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-04-19 10:01:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-19 10:01:04 +0200 |
commit | 9874981e757f0e2658baa3a871450509cee9204c (patch) | |
tree | 579327324492541a765b465b467cea0d50354e36 | |
parent | 4005f0d0e40fb57efd8144c065a7ba56d940b572 (diff) | |
download | Nim-9874981e757f0e2658baa3a871450509cee9204c.tar.gz |
fixes #14001 (#14004)
-rw-r--r-- | compiler/sigmatch.nim | 2 | ||||
-rw-r--r-- | compiler/types.nim | 2 | ||||
-rw-r--r-- | drnim/drnim.nim | 1 | ||||
-rw-r--r-- | lib/system/iterators_1.nim | 10 |
4 files changed, 8 insertions, 7 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index d819afb42..6c8f926dd 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1276,7 +1276,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, of tyNil: result = allowsNilDeprecated(c, f) else: discard of tyOrdinal: - if isOrdinalType(a): + if isOrdinalType(a, allowEnumWithHoles = optNimV1Emulation in c.c.config.globalOptions): var x = if a.kind == tyOrdinal: a[0] else: a if f[0].kind == tyNone: result = isGeneric diff --git a/compiler/types.nim b/compiler/types.nim index ecbe371e2..c55ecd2aa 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -161,7 +161,7 @@ proc enumHasHoles*(t: PType): bool = proc isOrdinalType*(t: PType, allowEnumWithHoles: bool = false): bool = assert(t != nil) const - baseKinds = {tyChar,tyInt..tyInt64,tyUInt..tyUInt64,tyBool,tyEnum} + baseKinds = {tyChar, tyInt..tyInt64, tyUInt..tyUInt64, tyBool, tyEnum} parentKinds = {tyRange, tyOrdinal, tyGenericInst, tyAlias, tySink, tyDistinct} result = (t.kind in baseKinds and (not t.enumHasHoles or allowEnumWithHoles)) or (t.kind in parentKinds and isOrdinalType(t.lastSon, allowEnumWithHoles)) diff --git a/drnim/drnim.nim b/drnim/drnim.nim index 6c08bed42..789cf74cf 100644 --- a/drnim/drnim.nim +++ b/drnim/drnim.nim @@ -9,6 +9,7 @@ #[ +- introduce Phi nodes to complete the SSA representation - the analysis has to take 'break', 'continue' and 'raises' into account - We need to map arrays to Z3 and test for something like 'forall(i, (i in 3..4) -> (a[i] > 3))' - We need teach DrNim what 'inc', 'dec' and 'swap' mean, for example diff --git a/lib/system/iterators_1.nim b/lib/system/iterators_1.nim index 07c731c3b..262bd6aab 100644 --- a/lib/system/iterators_1.nim +++ b/lib/system/iterators_1.nim @@ -24,7 +24,7 @@ iterator countdown*[T](a, b: T, step: Positive = 1): T {.inline.} = yield res if res == b: break dec(res, step) - elif T is IntLikeForCount: + elif T is IntLikeForCount and T is Ordinal: var res = int(a) while res >= int(b): yield T(res) @@ -52,7 +52,7 @@ when defined(nimNewRoof): ## for i in countup(2, 9, 3): ## echo i # => 2; 5; 8 mixin inc - when T is IntLikeForCount: + when T is IntLikeForCount and T is Ordinal: var res = int(a) while res <= int(b): yield T(res) @@ -73,7 +73,7 @@ when defined(nimNewRoof): ## for i in 3 .. 7: ## echo i # => 3; 4; 5; 6; 7 mixin inc - when T is IntLikeForCount: + when T is IntLikeForCount and T is Ordinal: var res = int(a) while res <= int(b): yield T(res) @@ -138,7 +138,7 @@ else: # not defined(nimNewRoof) ## ## for i in countup(2, 9, 3): ## echo i # => 2; 5; 8 - when T is IntLikeForCount: + when T is IntLikeForCount and T is Ordinal: var res = int(a) while res <= int(b): yield T(res) @@ -159,7 +159,7 @@ else: # not defined(nimNewRoof) ## for i in 3 .. 7: ## echo i # => 3; 4; 5; 6; 7 mixin inc - when T is IntLikeForCount: + when T is IntLikeForCount and T is Ordinal: var res = int(a) while res <= int(b): yield T(res) |