Fix compilation for 1.4

Since proc params are now turned into syms during sem
we need to "refresh" them for use in another context
This commit is contained in:
Clyybber 2020-10-11 16:56:40 +02:00 committed by zah
parent cc0d15ccac
commit 13089cad4c
1 changed files with 9 additions and 1 deletions

View File

@ -247,6 +247,13 @@ proc outputParamType*(msg: Message): NimNode =
if outputParam != nil: if outputParam != nil:
return outputParam[1] return outputParam[1]
proc refreshParam(n: NimNode): NimNode =
result = copyNimTree(n)
if n.kind == nnkIdentDefs:
for i in 0..<n.len-2:
if n[i].kind == nnkSym:
result[i] = genSym(symKind(n[i]), $n[i])
iterator typedInputParams(procDef: NimNode, skip = 0): (NimNode, NimNode) = iterator typedInputParams(procDef: NimNode, skip = 0): (NimNode, NimNode) =
for paramName, paramType in typedParams(procDef, skip): for paramName, paramType in typedParams(procDef, skip):
if not isOutputParamName(paramName): if not isOutputParamName(paramName):
@ -256,7 +263,7 @@ proc copyInputParams(params: NimNode): NimNode =
result = newTree(params.kind) result = newTree(params.kind)
for param in params: for param in params:
if not isOutputParam(param): if not isOutputParam(param):
result.add param result.add param.refreshParam
proc chooseFieldType(n: NimNode): NimNode = proc chooseFieldType(n: NimNode): NimNode =
## Examines the parameter types used in the message signature ## Examines the parameter types used in the message signature
@ -790,6 +797,7 @@ proc createHandshakeTemplate*(msg: Message,
forwardCall[1] = peerVar forwardCall[1] = peerVar
forwardCall.del(forwardCall.len - 1) forwardCall.del(forwardCall.len - 1)
let peerVar = genSym(nskLet ,"peer")
handshakeExchanger.setBody quote do: handshakeExchanger.setBody quote do:
let `peerVar` = `peerValue` let `peerVar` = `peerValue`
let sendingFuture = `forwardCall` let sendingFuture = `forwardCall`