summary refs log tree commit diff stats
path: root/compiler/sigmatch.nim
diff options
context:
space:
mode:
authorcooldome <ariabushenko@bk.ru>2018-06-10 23:27:45 +0100
committercooldome <ariabushenko@bk.ru>2018-06-10 23:27:45 +0100
commita65e9c0e2520911d16b81e7af47fea8c3fdd2958 (patch)
tree394894bbdf96fdffffd7328ca8194391d9e567c5 /compiler/sigmatch.nim
parent4d87d666ee12d9a16a0a3b21ab30b46f9e933cb0 (diff)
downloadNim-a65e9c0e2520911d16b81e7af47fea8c3fdd2958.tar.gz
fix comments
Diffstat (limited to 'compiler/sigmatch.nim')
-rw-r--r--compiler/sigmatch.nim27
1 files changed, 11 insertions, 16 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index ec13b7557..bdae01d7d 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -633,26 +633,21 @@ proc procTypeRel(c: var TCandidate, f, a: PType): TTypeRelation =
   else: discard
 
 proc typeRangeRel(f, a: PType): TTypeRelation {.noinline.} =
-  template check_range_in(t: typedesc): untyped = 
-    let
-      a0 = firstValue[t](a)
-      a1 = lastValue[t](a)
-      f0 = firstValue[t](f)
-      f1 = lastValue[t](f)
-    if a0 == f0 and a1 == f1:
-      result = isEqual
-    elif a0 >= f0 and a1 <= f1:
-      result = isConvertible
-    elif a0 <= f1 and f0 <= a1:
+  template check_range[T](a_first, a_last, f_first, f_last: T): TTypeRelation = 
+    if a_first == f_first and a_last == f_last:
+      isEqual
+    elif a_first >= f_first and a_last <= f_last:
+      isConvertible
+    elif a_first <= f_last and f_first <= a_last:
       # X..Y and C..D overlap iff (X <= D and C <= Y)
-      result = isConvertible
+      isConvertible
     else:
-      result = isNone
+      isNone
   
   if f.isOrdinalType: 
-    check_range_in(BiggestInt)
-  else:
-    check_range_in(BiggestFloat)
+    check_range(firstOrd(a), lastOrd(a), firstOrd(f), lastOrd(f))
+  else: 
+    check_range(firstFloat(a), lastFloat(a), firstFloat(f), lastFloat(f))
     
 
 proc matchUserTypeClass*(m: var TCandidate; ff, a: PType): PType =