fixes #2007
This commit is contained in:
parent
164ebb6762
commit
1a2bda45ec
3 changed files with 63 additions and 5 deletions
|
|
@ -162,9 +162,9 @@ proc addHiddenParam(routine: PSym, param: PSym) =
|
||||||
# some nkEffect node:
|
# some nkEffect node:
|
||||||
param.position = routine.typ.n.len-1
|
param.position = routine.typ.n.len-1
|
||||||
addSon(params, newSymNode(param))
|
addSon(params, newSymNode(param))
|
||||||
incl(routine.typ.flags, tfCapturesEnv)
|
#incl(routine.typ.flags, tfCapturesEnv)
|
||||||
assert sfFromGeneric in param.flags
|
assert sfFromGeneric in param.flags
|
||||||
#echo "produced environment: ", param.id, " for ", routine.name.s
|
#echo "produced environment: ", param.id, " for ", routine.id
|
||||||
|
|
||||||
proc getHiddenParam(routine: PSym): PSym =
|
proc getHiddenParam(routine: PSym): PSym =
|
||||||
let params = routine.ast.sons[paramsPos]
|
let params = routine.ast.sons[paramsPos]
|
||||||
|
|
|
||||||
|
|
@ -958,15 +958,17 @@ proc semInferredLambda(c: PContext, pt: TIdTable, n: PNode): PNode =
|
||||||
var n = n
|
var n = n
|
||||||
|
|
||||||
let original = n.sons[namePos].sym
|
let original = n.sons[namePos].sym
|
||||||
let s = copySym(original, false)
|
let s = original #copySym(original, false)
|
||||||
incl(s.flags, sfFromGeneric)
|
#incl(s.flags, sfFromGeneric)
|
||||||
|
#s.owner = original
|
||||||
|
|
||||||
n = replaceTypesInBody(c, pt, n, original)
|
n = replaceTypesInBody(c, pt, n, original)
|
||||||
result = n
|
result = n
|
||||||
s.ast = result
|
s.ast = result
|
||||||
n.sons[namePos].sym = s
|
n.sons[namePos].sym = s
|
||||||
n.sons[genericParamsPos] = emptyNode
|
n.sons[genericParamsPos] = emptyNode
|
||||||
let params = n.typ.n
|
# for LL we need to avoid wrong aliasing
|
||||||
|
let params = copyTree n.typ.n
|
||||||
n.sons[paramsPos] = params
|
n.sons[paramsPos] = params
|
||||||
s.typ = n.typ
|
s.typ = n.typ
|
||||||
for i in 1..<params.len:
|
for i in 1..<params.len:
|
||||||
|
|
@ -974,6 +976,7 @@ proc semInferredLambda(c: PContext, pt: TIdTable, n: PNode): PNode =
|
||||||
tyFromExpr, tyFieldAccessor}+tyTypeClasses:
|
tyFromExpr, tyFieldAccessor}+tyTypeClasses:
|
||||||
localError(params[i].info, "cannot infer type of parameter: " &
|
localError(params[i].info, "cannot infer type of parameter: " &
|
||||||
params[i].sym.name.s)
|
params[i].sym.name.s)
|
||||||
|
#params[i].sym.owner = s
|
||||||
openScope(c)
|
openScope(c)
|
||||||
pushOwner(s)
|
pushOwner(s)
|
||||||
addParams(c, params, skProc)
|
addParams(c, params, skProc)
|
||||||
|
|
|
||||||
55
tests/async/tlambda.nim
Normal file
55
tests/async/tlambda.nim
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
|
||||||
|
# bug 2007
|
||||||
|
|
||||||
|
import asyncdispatch, asyncnet, logging, json, uri, strutils, future
|
||||||
|
|
||||||
|
type
|
||||||
|
Builder = ref object
|
||||||
|
client: Client
|
||||||
|
build: Build
|
||||||
|
|
||||||
|
ProgressCB* = proc (message: string): Future[void] {.closure, gcsafe.}
|
||||||
|
|
||||||
|
Build* = ref object
|
||||||
|
onProgress*: ProgressCB
|
||||||
|
|
||||||
|
Client = ref ClientObj
|
||||||
|
ClientObj = object
|
||||||
|
onMessage: proc (client: Client, msg: JsonNode): Future[void]
|
||||||
|
|
||||||
|
proc newClient*(name: string,
|
||||||
|
onMessage: (Client, JsonNode) -> Future[void]): Client =
|
||||||
|
new result
|
||||||
|
result.onMessage = onMessage
|
||||||
|
|
||||||
|
proc newBuild*(onProgress: ProgressCB): Build =
|
||||||
|
new result
|
||||||
|
result.onProgress = onProgress
|
||||||
|
|
||||||
|
proc start(build: Build, repo, hash: string) {.async.} =
|
||||||
|
let path = repo.parseUri().path.toLower()
|
||||||
|
|
||||||
|
proc onProgress(builder: Builder, message: string) {.async.} =
|
||||||
|
debug($message)
|
||||||
|
|
||||||
|
proc onMessage(builder: Builder, message: JsonNode) {.async.} =
|
||||||
|
debug("onMessage")
|
||||||
|
|
||||||
|
proc newBuilder(): Builder =
|
||||||
|
var cres: Builder
|
||||||
|
new cres
|
||||||
|
|
||||||
|
cres.client = newClient("builder", (client, msg) => (onMessage(cres, msg)))
|
||||||
|
cres.build = newBuild(
|
||||||
|
proc (msg: string): Future[void] {.closure, gcsafe.} = onProgress(cres, msg))
|
||||||
|
return cres
|
||||||
|
|
||||||
|
proc main() =
|
||||||
|
# Set up logging.
|
||||||
|
var console = newConsoleLogger(fmtStr = verboseFmtStr)
|
||||||
|
addHandler(console)
|
||||||
|
|
||||||
|
var builder = newBuilder()
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue