From 0a14b3d1980e116bd40a98d5d2b414a0e1d05a1c Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 30 Jun 2018 09:16:14 +0200 Subject: [PATCH] Check the RHS when building a set (#8159) Fixes #2669 --- compiler/sem.nim | 2 +- tests/sets/t2669.nim | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/sets/t2669.nim diff --git a/compiler/sem.nim b/compiler/sem.nim index 0adcccfbe5..b242e4db62 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -76,7 +76,7 @@ template semIdeForTemplateOrGeneric(c: PContext; n: PNode; proc fitNodePostMatch(c: PContext, formal: PType, arg: PNode): PNode = result = arg let x = result.skipConv - if x.kind in {nkPar, nkTupleConstr} and formal.kind != tyExpr: + if x.kind in {nkPar, nkTupleConstr, nkCurly} and formal.kind != tyExpr: changeType(c, x, formal, check=true) else: result = skipHiddenSubConv(result) diff --git a/tests/sets/t2669.nim b/tests/sets/t2669.nim new file mode 100644 index 0000000000..6b8eb0f54c --- /dev/null +++ b/tests/sets/t2669.nim @@ -0,0 +1,6 @@ +discard """ +line: 6 +errormsg: "cannot convert 6 to range 1..5(int8)" +""" + +var c: set[range[1i8..5i8]] = {1i8, 2i8, 6i8}