From 2c91e999e29208f89ab6b0995b6942b69a1e23e3 Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 24 Apr 2015 20:28:39 +0200 Subject: fixes #2600 --- tests/overload/tspec.nim | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'tests/overload') diff --git a/tests/overload/tspec.nim b/tests/overload/tspec.nim index 685df503a..99966e93e 100644 --- a/tests/overload/tspec.nim +++ b/tests/overload/tspec.nim @@ -11,7 +11,8 @@ ref T 123 2 1 -@[123, 2, 1]''' +@[123, 2, 1] +Called!''' """ # Things that's even in the spec now! @@ -79,3 +80,31 @@ proc takeV[T](a: varargs[T]) = takeV([123, 2, 1]) # takeV's T is "int", not "array of int" echo(@[123, 2, 1]) + +# bug #2600 + +type + FutureBase* = ref object of RootObj ## Untyped future. + + Future*[T] = ref object of FutureBase ## Typed future. + value: T ## Stored value + + FutureVar*[T] = distinct Future[T] + +proc newFuture*[T](): Future[T] = + new(result) + +proc newFutureVar*[T](): FutureVar[T] = + result = FutureVar[T](newFuture[T]()) + +proc mget*[T](future: FutureVar[T]): var T = + Future[T](future).value + +proc reset*[T](future: FutureVar[T]) = + echo "Called!" + +when true: + var foo = newFutureVar[string]() + foo.mget() = "" + foo.mget.add("Foobar") + foo.reset() -- cgit 1.4.1-2-gfad0