mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-01 19:02:18 +00:00
Merge pull request #2496 from BlaXpirit/js-header-comma
Fix JS codegen: proc header with compiletime arguments
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user