summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorJasper Jenkins <jasper.vs.jenkins@gmail.com>2020-01-20 07:56:59 -0800
committerAndreas Rumpf <rumpf_a@web.de>2020-01-20 16:56:59 +0100
commit0606b6a44e2778697869ed33bff000a1548f36aa (patch)
treeb595df7737c047925c6ac7b96f3745b4b1b2c6c9 /compiler
parent470faa97c60aa5d8153f00083913aca4f0dc1fdf (diff)
downloadNim-0606b6a44e2778697869ed33bff000a1548f36aa.tar.gz
fix range[enum] type conversion (#13204) [backport]
Diffstat (limited to 'compiler')
-rw-r--r--compiler/sigmatch.nim5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index c87b76622..677afc2d5 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -1149,9 +1149,10 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
             f.n[i] = tryResolvingStaticExpr(c, f.n[i])
         result = typeRangeRel(f, a)
     else:
-      if skipTypes(f, {tyRange}).kind == a.kind:
+      let f = skipTypes(f, {tyRange})
+      if f.kind == a.kind and (f.kind != tyEnum or sameEnumTypes(f, a)):
         result = isIntConv
-      elif isConvertibleToRange(skipTypes(f, {tyRange}), a):
+      elif isConvertibleToRange(f, a):
         result = isConvertible  # a convertible to f
   of tyInt:      result = handleRange(f, a, tyInt8, tyInt32)
   of tyInt8:     result = handleRange(f, a, tyInt8, tyInt8)