Skip to content

Commit

Permalink
fixes #7167
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed May 21, 2019
1 parent bab5e30 commit df8004f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 1 addition & 2 deletions compiler/semexprs.nim
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/pure/times.nim
Expand Up @@ -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[]
Expand Down
15 changes: 15 additions & 0 deletions tests/distinct/tdistinct.nim
Expand Up @@ -2,6 +2,10 @@ discard """
output: '''
tdistinct
25
false
false
false
false
'''
"""

Expand Down Expand Up @@ -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'

0 comments on commit df8004f

Please sign in to comment.