From df5b7e8e3dc3f8f340077aa98a5b303095e9e457 Mon Sep 17 00:00:00 2001 From: Billingsly Wetherfordshire Date: Tue, 11 Sep 2012 22:56:34 -0500 Subject: nimrepl handles keys again --- tools/nimrepl.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/nimrepl.nim b/tools/nimrepl.nim index c43a7101d..8e43b4431 100755 --- a/tools/nimrepl.nim +++ b/tools/nimrepl.nim @@ -63,7 +63,7 @@ proc FileSaveClicked(menuitem: PMenuItem, userdata: pgpointer) {.cdecl.} = error(w, "Unable to write to file") proc inputKeyPressed(widget: PWidget, event: PEventKey, - userdata: pgpointer): bool = + userdata: pgpointer): bool {.cdecl.} = if ($keyval_name(event.keyval)).tolower() == "shift_l": # SHIFT is pressed shiftPressed = True @@ -72,7 +72,7 @@ proc setError(msg: string) = outputTextBuffer.setText(msg, msg.len.gint) proc inputKeyReleased(widget: PWidget, event: PEventKey, - userdata: pgpointer): bool = + userdata: pgpointer): bool {.cdecl.} = #echo(keyval_name(event.keyval)) if ($keyval_name(event.keyval)).tolower() == "shift_l": # SHIFT is released -- cgit 1.4.1-2-gfad0 From 9e4254e4de8cecff5c0a8026930ae79b68ca7c61 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 13 Sep 2012 00:33:01 +0300 Subject: type trais used to work only on user-defined types. see #202 --- compiler/evals.nim | 3 +-- tests/run/ttypetraits.nim | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/compiler/evals.nim b/compiler/evals.nim index bb0e5936d..3f801e123 100755 --- a/compiler/evals.nim +++ b/compiler/evals.nim @@ -864,8 +864,7 @@ proc evalTypeTrait*(n: PNode, context: PSym): PNode = ## XXX: This should be pretty much guaranteed to be true # by the type traits procs' signatures, but until the # code is more mature it doesn't hurt to be extra safe - internalAssert n.sons.len >= 2 and n.sons[1].kind == nkSym and - n.sons[1].sym.typ.kind == tyTypeDesc + internalAssert n.sons.len >= 2 and n.sons[1].kind == nkSym let typ = n.sons[1].sym.typ.skipTypes({tyTypeDesc}) case n.sons[0].sym.name.s.normalize diff --git a/tests/run/ttypetraits.nim b/tests/run/ttypetraits.nim index 5b683bef0..cba610871 100644 --- a/tests/run/ttypetraits.nim +++ b/tests/run/ttypetraits.nim @@ -1,10 +1,11 @@ discard """ msg: "int\nstring\nTBar[int]" - output: "int\nstring\nTBar[int]" + output: "int\nstring\nTBar[int]\nint\nrange 0..2" """ import typetraits +# simple case of type trait usage inside/outside of static blocks proc foo(x) = static: var t = type(x) @@ -22,3 +23,16 @@ foo 10 foo "test" foo bar +# generic params on user types work too +proc foo2[T](x: TBar[T]) = + echo T.name + +foo2 bar + +# less usual generic params on built-in types +var arr: array[0..2, int] = [1, 2, 3] + +proc foo3[R, T](x: array[R, T]) = + echo name(R) + +foo3 arr -- cgit 1.4.1-2-gfad0