Fixed $ on None[T] for T with .name (#8293)

This commit is contained in:
Quelklef
2018-07-12 05:01:48 -04:00
committed by Andreas Rumpf
parent 32441d01e5
commit ac3c4a94ad

View File

@@ -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]")