From df8004f285894f012ab672243b170d7d784aec4a Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Wed, 22 May 2019 00:26:05 +0200 Subject: [PATCH] fixes #7167 --- compiler/semexprs.nim | 3 +-- lib/pure/times.nim | 2 +- tests/distinct/tdistinct.nim | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 767a13f3ecf6..2689821475aa 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/lib/pure/times.nim b/lib/pure/times.nim index 96c14bf5b56f..513eb4c47c8a 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).clong, high(CTime).clong).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 70e586ded3eb..c6bfb2490e56 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'