summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-11-16 21:59:21 +0100
committerAraq <rumpf_a@web.de>2014-11-16 21:59:21 +0100
commitfd532b6dab930db7f456700f791065f22c155f9c (patch)
tree9a7798784af491c739520d0f77c6e3e7fec603d1
parent69a994b59ee91d3221fe7a696cd40671b15e335b (diff)
downloadNim-fd532b6dab930db7f456700f791065f22c155f9c.tar.gz
fixes #206
-rw-r--r--compiler/patterns.nim2
-rw-r--r--tests/trmacros/tnoalias2.nim19
2 files changed, 20 insertions, 1 deletions
diff --git a/compiler/patterns.nim b/compiler/patterns.nim
index 3d71aa4d1..9ac0988c5 100644
--- a/compiler/patterns.nim
+++ b/compiler/patterns.nim
@@ -260,7 +260,7 @@ proc applyRule*(c: PContext, s: PSym, n: PNode): PNode =
     # couldn't bind parameter:
     if isNil(x): return nil
     result.add(x)
-    if requiresAA: addToArgList(args, n)
+    if requiresAA: addToArgList(args, x)
   # perform alias analysis here:
   if requiresAA:
     for i in 1 .. < params.len:
diff --git a/tests/trmacros/tnoalias2.nim b/tests/trmacros/tnoalias2.nim
new file mode 100644
index 000000000..5a816acb9
--- /dev/null
+++ b/tests/trmacros/tnoalias2.nim
@@ -0,0 +1,19 @@
+discard """
+  output: '''0'''
+"""
+
+# bug #206
+template optimizeOut{testFunc(a, b)}(a: int, b: int{alias}) : expr = 0
+
+proc testFunc(a, b: int): int = result = a + b
+var testVar = 1
+echo testFunc(testVar, testVar)
+
+
+template ex{a = b + c}(a : int{noalias}, b, c : int) =
+  a = b
+  inc a, b
+  echo "came here"
+
+var x = 5
+x = x + x