From 57250ad2819a14ccbe325f33d6afcd06dd18ea35 Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Thu, 9 Apr 2015 04:19:00 +0300 Subject: [PATCH 1/2] Test JS proc header codegen --- tests/js/test2.nim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/js/test2.nim b/tests/js/test2.nim index 5a734358c..1a42fbfda 100644 --- a/tests/js/test2.nim +++ b/tests/js/test2.nim @@ -1,6 +1,7 @@ discard """ output: '''foo -js 3.14''' +js 3.14 +7''' """ # This file tests the JavaScript generator @@ -20,3 +21,11 @@ else: proc foo(val: float): string = "js " & $val echo foo(3.14) + +# #2495 +type C = concept x + +proc test(x: C, T: typedesc): T = + cast[T](x) + +echo 7.test(int8) From 1d7fc5fcdaa0e16ac6583709248ba4635129807b Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Thu, 9 Apr 2015 03:36:53 +0300 Subject: [PATCH 2/2] Don't add a comma too soon Fixes #2495 --- compiler/jsgen.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 382fe49df..6c667a3a7 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -791,10 +791,10 @@ proc genIf(p: PProc, n: PNode, r: var TCompRes) = proc generateHeader(p: PProc, typ: PType): Rope = result = nil for i in countup(1, sonsLen(typ.n) - 1): - if result != nil: add(result, ", ") assert(typ.n.sons[i].kind == nkSym) var param = typ.n.sons[i].sym if isCompileTimeOnly(param.typ): continue + if result != nil: add(result, ", ") var name = mangleName(param) add(result, name) if mapType(param.typ) == etyBaseIndex: