mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-30 19:23:57 +00:00
Param name and type combos now work in type sig. sugar.
This commit is contained in:
@@ -26,8 +26,15 @@ proc createProcType(p, b: PNimrodNode): PNimrodNode {.compileTime.} =
|
||||
for i in 0 .. <p.len:
|
||||
let ident = p[i]
|
||||
var identDefs = newNimNode(nnkIdentDefs)
|
||||
identDefs.add newIdentNode("i" & $i)
|
||||
identDefs.add(ident)
|
||||
case ident.kind
|
||||
of nnkExprColonExpr:
|
||||
identDefs.add ident[0]
|
||||
identDefs.add ident[1]
|
||||
of nnkIdent:
|
||||
identDefs.add newIdentNode("i" & $i)
|
||||
identDefs.add(ident)
|
||||
else:
|
||||
error("Incorrect type list in proc type declaration.")
|
||||
identDefs.add newEmptyNode()
|
||||
formalParams.add identDefs
|
||||
of nnkIdent:
|
||||
|
||||
@@ -5,6 +5,7 @@ discard """
|
||||
3
|
||||
3
|
||||
noReturn
|
||||
6
|
||||
'''
|
||||
"""
|
||||
|
||||
@@ -36,8 +37,7 @@ echo doWithOneAndTwo((x, y) => x + y)
|
||||
|
||||
noReturn(() -> void => echo("noReturn"))
|
||||
|
||||
when false:
|
||||
proc pass2(f: (int, int) -> int): (int) -> int =
|
||||
(x: int) -> int => f(2, x)
|
||||
proc pass2(f: (int, int) -> int): (int) -> int =
|
||||
(x: int) -> int => f(2, x)
|
||||
|
||||
#echo pass2((x, y) => x + y)
|
||||
echo pass2((x, y) => x + y)(4)
|
||||
|
||||
Reference in New Issue
Block a user