From cf7e83ecc5be0a85d5e669c9c7d5b3753b075371 Mon Sep 17 00:00:00 2001 From: Araq Date: Sun, 6 Apr 2014 17:26:20 +0200 Subject: [PATCH] fixes #913 --- compiler/nimrod.nimrod.cfg | 1 + compiler/sigmatch.nim | 2 ++ tests/typerel/tvarargsexpr.nim | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 tests/typerel/tvarargsexpr.nim diff --git a/compiler/nimrod.nimrod.cfg b/compiler/nimrod.nimrod.cfg index cc27d9f36c..2c6e6f2495 100644 --- a/compiler/nimrod.nimrod.cfg +++ b/compiler/nimrod.nimrod.cfg @@ -20,3 +20,4 @@ import:testability define:useStdoutAsStdmsg cs:partial +#define:useNodeIds diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index b9fb0c9572..b83c27d221 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -668,6 +668,8 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation = result = isNone else: discard of tyOpenArray, tyVarargs: + # varargs[expr] is special + if f.kind == tyVarargs and f.sons[0].kind == tyExpr: return case a.kind of tyOpenArray, tyVarargs: result = typeRel(c, base(f), base(a)) diff --git a/tests/typerel/tvarargsexpr.nim b/tests/typerel/tvarargsexpr.nim new file mode 100644 index 0000000000..fcb49af610 --- /dev/null +++ b/tests/typerel/tvarargsexpr.nim @@ -0,0 +1,18 @@ +discard """ + output: '''success''' +""" + +#bug #913 + +import macros + +macro thirteen(args: varargs[expr]): expr = + result = newIntLitNode(13) + +doAssert(13==thirteen([1,2])) # works +doAssert(13==thirteen(1,2)) # works + +doAssert(13==thirteen(1,[2])) # does not work +doAssert(13==thirteen([1], 2)) # does not work + +echo "success"