From 70b5efa98de87bd7684b7258cb95fb2b9892b6df Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 31 Dec 2014 12:58:22 +0200 Subject: [PATCH] fix #544 --- compiler/sigmatch.nim | 3 ++- tests/misc/tvarious.nim | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 6d6e26b2d6..8fea81bee6 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -629,6 +629,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation = elif skipTypes(a, {tyRange}).kind == f.kind: result = isSubtype of tyRange: if a.kind == f.kind: + if f.base.kind == tyNone: return isGeneric result = typeRel(c, base(f), base(a)) # bugfix: accept integer conversions here #if result < isGeneric: result = isNone @@ -948,7 +949,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation = else: internalAssert a.sons != nil and a.sons.len > 0 c.typedescMatched = true - result = typeRel(c, f.base, a.base) + result = typeRel(c, f.base, a.skipTypes({tyGenericParam, tyTypeDesc})) else: result = isNone else: diff --git a/tests/misc/tvarious.nim b/tests/misc/tvarious.nim index 0daa019a9c..8124b3fc70 100644 --- a/tests/misc/tvarious.nim +++ b/tests/misc/tvarious.nim @@ -51,17 +51,17 @@ while i < s.len: write(stdout, "Du heißt " & s) # bug #544 -when false: - # yay, fails again - type Bar [T; I:range] = array[I, T] - proc foo*[T; I:range](a, b: Bar[T, I]): Bar[T, I] = - when len(a) != 3: - # Error: constant expression expected - {.fatal:"Dimensions have to be 3".} - #... - block: - var a, b: Bar[int, 0..2] - discard foo(a, b) + +# yay, fails again +type Bar [T; I:range] = array[I, T] +proc foo*[T; I:range](a, b: Bar[T, I]): Bar[T, I] = + when len(a) != 3: + # Error: constant expression expected + {.fatal:"Dimensions have to be 3".} + #... +block: + var a, b: Bar[int, range[0..2]] + discard foo(a, b) # bug #1788