From ae5d8fbd9d6b0c6469c2245da8a54d7b4c12f54f Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 21 Jan 2019 17:27:36 +0100 Subject: [PATCH] Proper check for tyStatic[T] -> U conversions (#10382) Drop the outer tyStatic shell then perform the check. Fixes #7609 --- compiler/semexprs.nim | 2 ++ tests/statictypes/tstatictypes.nim | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 5e1e4cbbd0..82f948492c 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -108,6 +108,8 @@ const proc checkConvertible(c: PContext, castDest, src: PType): TConvStatus = result = convOK + # We're interested in the inner type and not in the static tag + var src = src.skipTypes({tyStatic}) if sameType(castDest, src) and castDest.sym == src.sym: # don't annoy conversions that may be needed on another processor: if castDest.kind notin IntegralTypes+{tyRange}: diff --git a/tests/statictypes/tstatictypes.nim b/tests/statictypes/tstatictypes.nim index 9888165cce..b7cde61247 100644 --- a/tests/statictypes/tstatictypes.nim +++ b/tests/statictypes/tstatictypes.nim @@ -132,3 +132,8 @@ block: var x = foo(y, 10, 15, [1, 2, 3]) doAssert x == (20, 10, 15, 3) +# #7609 +block: + type + Coord[N: static[int]] = tuple[col, row: range[0'i8 .. (N.int8-1)]] + Point[N: static[int]] = range[0'i16 .. N.int16 * N.int16 - 1]