Skip to content

Commit

Permalink
revert back to simpler implementation now that #8693 was fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Aug 22, 2018
1 parent a1e29f8 commit bfa0b66
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/pure/typetraits.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
## This module defines compile-time reflection procs for
## working with types

import macros

proc name*(t: typedesc): string {.magic: "TypeTrait".}
## Returns the name of the given type.
##
Expand Down Expand Up @@ -59,16 +57,17 @@ proc supportsCopyMem*(t: typedesc): bool {.magic: "TypeTrait".}
## This trait returns true iff the type ``t`` is safe to use for
## `copyMem`:idx:. Other languages name a type like these `blob`:idx:.

macro `==`*(t1, t2: typedesc): untyped =
proc `==`*(t1, t2: typedesc): bool =
## Returns whether ``t1`` and ``t2`` are the same type; this is different
## from ``t1 is t2`` since the latter supports concepts & inheritance.
runnableExamples:
type T = int
doAssert T == int
doAssert int == T
doAssert: int != float
# Note: t1 is t2 and t2 is t1 ran into https://github.com/nim-lang/Nim/issues/8693
newLit sameType(t1.getType[1], t2.getType[1])
# Should be same as a macro returning:
# `newLit sameType(t1.getType[1], t2.getType[1])`
t1 is t2 and t2 is t1

when isMainModule:
doAssert $type(42) == "int"
Expand Down

0 comments on commit bfa0b66

Please sign in to comment.