From 9a2b98cd8bb7b4220b1ee959ce2af730f4770cc6 Mon Sep 17 00:00:00 2001 From: Matthew Baulch Date: Sat, 3 Sep 2016 21:21:06 +1000 Subject: [PATCH] Add a test case for issue #4675. --- tests/overload/importA.nim | 5 +++++ tests/overload/importB.nim | 15 +++++++++++++++ tests/overload/timport.nim | 7 +++++++ 3 files changed, 27 insertions(+) create mode 100644 tests/overload/importA.nim create mode 100644 tests/overload/importB.nim create mode 100644 tests/overload/timport.nim diff --git a/tests/overload/importA.nim b/tests/overload/importA.nim new file mode 100644 index 000000000..f045d11b4 --- /dev/null +++ b/tests/overload/importA.nim @@ -0,0 +1,5 @@ +type + Field* = object + elemSize*: int + +template `+`*(x: untyped, y: Field): untyped = x diff --git a/tests/overload/importB.nim b/tests/overload/importB.nim new file mode 100644 index 000000000..2dc3adf7a --- /dev/null +++ b/tests/overload/importB.nim @@ -0,0 +1,15 @@ +type + Foo*[T] = object + v*: T + +template `+`*(x: Foo, y: Foo): untyped = x + +template newvar*(r: untyped): untyped {.dirty.} = + var r: float + +template t1*(x: Foo): untyped = + newvar(y1) + x +template t2*(x: Foo): untyped = + newvar(y2) + x diff --git a/tests/overload/timport.nim b/tests/overload/timport.nim new file mode 100644 index 000000000..8ea65e54d --- /dev/null +++ b/tests/overload/timport.nim @@ -0,0 +1,7 @@ +# issue 4675 +import importA # comment this out to make it work +import importB + +var x: Foo[float] +var y: Foo[float] +let r = t1(x) + t2(y)