summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-08-04 00:30:08 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-08-04 01:37:41 +0200
commit6d98c717deb16d265fb1d26528182eb16b07f784 (patch)
treefea8a5d5a861ae8d5522b3321ec63118225744b3
parent186bfe447515cd32916415f3b8675120f1a9f9ff (diff)
downloadNim-6d98c717deb16d265fb1d26528182eb16b07f784.tar.gz
fixes #4564
-rw-r--r--compiler/semexprs.nim8
-rw-r--r--tests/template/mlt.nim3
-rw-r--r--tests/template/tlt.nim7
3 files changed, 15 insertions, 3 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 70f795d4a..fd18dc3d7 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -752,14 +752,16 @@ proc semIndirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
   var prc = n.sons[0]
   if n.sons[0].kind == nkDotExpr:
     checkSonsLen(n.sons[0], 2)
-    n.sons[0] = semFieldAccess(c, n.sons[0])
-    if n.sons[0].kind == nkDotCall:
+    let n0 = semFieldAccess(c, n.sons[0])
+    if n0.kind == nkDotCall:
       # it is a static call!
-      result = n.sons[0]
+      result = n0
       result.kind = nkCall
       result.flags.incl nfExplicitCall
       for i in countup(1, sonsLen(n) - 1): addSon(result, n.sons[i])
       return semExpr(c, result, flags)
+    else:
+      n.sons[0] = n0
   else:
     n.sons[0] = semExpr(c, n.sons[0], {efInCall})
     let t = n.sons[0].typ
diff --git a/tests/template/mlt.nim b/tests/template/mlt.nim
new file mode 100644
index 000000000..e567cf085
--- /dev/null
+++ b/tests/template/mlt.nim
@@ -0,0 +1,3 @@
+
+type Point* = ref object of RootObj
+proc `>`*(p1, p2: Point): bool = false
diff --git a/tests/template/tlt.nim b/tests/template/tlt.nim
new file mode 100644
index 000000000..75c7dd991
--- /dev/null
+++ b/tests/template/tlt.nim
@@ -0,0 +1,7 @@
+
+import mlt
+# bug #4564
+type Bar* = ref object of RootObj
+proc foo(a: Bar): int = 0
+var a: Bar
+let b = a.foo() > 0