summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/options.nim16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/pure/options.nim b/lib/pure/options.nim
index bd01b208a..ce58943f9 100644
--- a/lib/pure/options.nim
+++ b/lib/pure/options.nim
@@ -189,7 +189,7 @@ proc `$`*[T](self: Option[T]): string =
   if self.isSome:
     "Some(" & $self.val & ")"
   else:
-    "None[" & T.name & "]"
+    "None[" & name(T) & "]"
 
 when isMainModule:
   import unittest, sequtils
@@ -298,3 +298,17 @@ when isMainModule:
     test "none[T]":
       check(none[int]().isNone)
       check(none(int) == none[int]())
+
+    test "$ on typed with .name":
+      type Named = object
+        name: string
+
+      let nobody = none(Named)
+      check($nobody == "None[Named]")
+
+    test "$ on type with name()":
+      type Person = object
+        myname: string
+
+      let noperson = none(Person)
+      check($noperson == "None[Person]")