added system.default in order to prevent the abstraction inversion that 'template default(T): untyped = (var x: T; x)' causes

This commit is contained in:
Andreas Rumpf 2019-03-05 09:54:59 +01:00
commit 142a2d3551
7 changed files with 50 additions and 11 deletions

View file

@ -4278,6 +4278,10 @@ proc `$`*(t: typedesc): string {.magic: "TypeTrait".} =
doAssert $(type("Foo")) == "string"
static: doAssert $(type(@['A', 'B'])) == "seq[char]"
when defined(nimHasDefault):
proc default*(T: typedesc): T {.magic: "Default", noSideEffect.}
## returns the default value of the type ``T``.
import system/widestrs
export widestrs