summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/semexprs.nim3
-rw-r--r--doc/manual.rst7
-rw-r--r--lib/pure/times.nim2
-rw-r--r--tests/distinct/tdistinct.nim15
4 files changed, 23 insertions, 4 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 767a13f3e..268982147 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -338,8 +338,7 @@ proc semLowHigh(c: PContext, n: PNode, m: TMagic): PNode =
     of tyArray:
       n.typ = typ.sons[0] # indextype
     of tyInt..tyInt64, tyChar, tyBool, tyEnum, tyUInt8, tyUInt16, tyUInt32, tyFloat..tyFloat64:
-      # do not skip the range!
-      n.typ = n.sons[1].typ.skipTypes(abstractVar)
+      n.typ = n.sons[1].typ.skipTypes({tyTypeDesc})
     of tyGenericParam:
       # prepare this for resolving in semtypinst:
       # we must use copyTree here in order to avoid creating a cycle
diff --git a/doc/manual.rst b/doc/manual.rst
index 50fbabd9d..53f900ae3 100644
--- a/doc/manual.rst
+++ b/doc/manual.rst
@@ -827,7 +827,10 @@ Ordinal types have the following characteristics:
 
 Integers, bool, characters and enumeration types (and subranges of these
 types) belong to ordinal types. For reasons of simplicity of implementation
-the types ``uint`` and ``uint64`` are not ordinal types.
+the types ``uint`` and ``uint64`` are not ordinal types. (This will be changed
+in later versions of the language.)
+
+A distinct type is an ordinal type if its base type is an ordinal type.
 
 
 Pre-defined integer types
@@ -1801,6 +1804,8 @@ and its base type. Explicit type conversions from a distinct type to its
 base type and vice versa are allowed. See also ``distinctBase`` to get the
 reverse operation.
 
+A distinct type is an ordinal type if its base type is an ordinal type.
+
 
 Modelling currencies
 ~~~~~~~~~~~~~~~~~~~~
diff --git a/lib/pure/times.nim b/lib/pure/times.nim
index 96c14bf5b..45ff8abe4 100644
--- a/lib/pure/times.nim
+++ b/lib/pure/times.nim
@@ -1102,7 +1102,7 @@ else:
 
     # In case of a 32-bit time_t, we fallback to the closest available
     # timezone information.
-    var a = clamp(unix, low(CTime), high(CTime)).CTime
+    var a = clamp(unix, low(CTime).int64, high(CTime).int64).CTime
     let tmPtr = localtime(a)
     if not tmPtr.isNil:
       let tm = tmPtr[]
diff --git a/tests/distinct/tdistinct.nim b/tests/distinct/tdistinct.nim
index 70e586ded..c6bfb2490 100644
--- a/tests/distinct/tdistinct.nim
+++ b/tests/distinct/tdistinct.nim
@@ -2,6 +2,10 @@ discard """
   output: '''
 tdistinct
 25
+false
+false
+false
+false
 '''
 """
 
@@ -83,3 +87,14 @@ type
 const d: DistTup = DistTup((
   foo:"FOO", bar:"BAR"
 ))
+
+
+# bug #7167
+
+type Id = distinct range[0..3]
+
+proc `<=`(a, b: Id): bool {.borrow.}
+
+var xs: array[Id, bool]
+
+for x in xs: echo x # type mismatch: got (T) but expected 'bool'