the is operator now works with type classes and type variables

bugfixes:
the DLL tests were failing on Mac OS X, due to an incorrect DynlibFormat
This commit is contained in:
Zahary Karadjov
2012-10-02 16:45:34 +03:00
parent 770d4a997e
commit 9c8bc3a244
13 changed files with 162 additions and 88 deletions

42
tests/compile/tisop.nim Normal file
View File

@@ -0,0 +1,42 @@
import typetraits
type
TRecord = (tuple) or (object)
TFoo[T, U] = object
x: int
when T is string:
y: float
else:
y: string
when U is TRecord:
z: float
E = enum A, B, C
macro m(t: typedesc): typedesc =
if t is enum:
result = string
else:
result = int
var f: TFoo[int, int]
static: assert(f.y.type.name == "string")
when compiles(f.z):
{.error: "Foo should not have a `z` field".}
proc p(a, b) =
when a.type is int:
static: assert false
var f: TFoo[m(a.type), b.type]
static:
assert f.x.type.name == "int"
assert f.y.type.name == "float"
assert f.z.type.name == "float"
p(A, f)

View File

@@ -2,8 +2,8 @@ type
TFoo[T] = object
val: T
T1 = distinct expr
T2 = distinct expr
T1 = expr
T2 = expr
proc takesExpr(x, y) =
echo x, y

View File

@@ -1,11 +1,11 @@
discard """
file: "tcaseexpr1.nim"
line: 23
errormsg: "not all cases are covered"
line: 29
errormsg: "type mismatch: got (string) but expected 'int'"
line: 23
errormsg: "not all cases are covered"
"""
type

View File

@@ -1,6 +1,6 @@
discard """
file: "system.nim"
line: 643
line: 649
errormsg: "type mismatch"
"""