mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
'let' within 'parallel' now works
This commit is contained in:
@@ -335,7 +335,7 @@ proc analyse(c: var AnalysisCtx; n: PNode) =
|
||||
localError(n.info, "invalid control flow for 'parallel'")
|
||||
# 'break' that leaves the 'parallel' section is not valid either
|
||||
# or maybe we should generate a 'try' XXX
|
||||
of nkVarSection:
|
||||
of nkVarSection, nkLetSection:
|
||||
for it in n:
|
||||
let value = it.lastSon
|
||||
if value.kind != nkEmpty:
|
||||
@@ -396,7 +396,7 @@ proc transformSpawnSons(owner: PSym; n, barrier: PNode): PNode =
|
||||
|
||||
proc transformSpawn(owner: PSym; n, barrier: PNode): PNode =
|
||||
case n.kind
|
||||
of nkVarSection:
|
||||
of nkVarSection, nkLetSection:
|
||||
result = nil
|
||||
for it in n:
|
||||
let b = it.lastSon
|
||||
|
||||
@@ -599,7 +599,7 @@ proc track(tracked: PEffects, n: PNode) =
|
||||
addAsgnFact(tracked.guards, n.sons[0], n.sons[1])
|
||||
notNilCheck(tracked, n.sons[1], n.sons[0].typ)
|
||||
when false: cstringCheck(tracked, n)
|
||||
of nkVarSection:
|
||||
of nkVarSection, nkLetSection:
|
||||
for child in n:
|
||||
let last = lastSon(child)
|
||||
if child.kind == nkIdentDefs and last.kind != nkEmpty:
|
||||
|
||||
14
tests/parallel/tlet_spawn.nim
Normal file
14
tests/parallel/tlet_spawn.nim
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
import threadpool
|
||||
|
||||
proc foo(): int = 999
|
||||
|
||||
# test that the disjoint checker deals with 'a = spawn f(); g = spawn f()':
|
||||
|
||||
proc main =
|
||||
parallel:
|
||||
let f = spawn foo()
|
||||
let b = spawn foo()
|
||||
echo "done", f, " ", b
|
||||
|
||||
main()
|
||||
7
todo.txt
7
todo.txt
@@ -2,10 +2,12 @@ version 0.10
|
||||
============
|
||||
|
||||
- Test nimfix on various babel packages
|
||||
- Pegs do not work at compile-time
|
||||
- deprecate recursive tuples; tuple needs laxer type checking
|
||||
- string case should require an 'else'
|
||||
- # echo type.int
|
||||
- VM: try does not work at all
|
||||
- VM: Pegs do not work at compile-time
|
||||
- VM: ptr/ref T cannot work in general
|
||||
|
||||
version 0.9.6
|
||||
=============
|
||||
@@ -22,7 +24,6 @@ Concurrency
|
||||
generics *when the type is constructed*
|
||||
- test 'deepCopy'
|
||||
|
||||
- the disjoint checker needs to deal with 'a = spawn f(); g = spawn f()'
|
||||
- implement 'foo[1..4] = spawn(f[4..7])'
|
||||
- document the new 'spawn' and 'parallel' statements
|
||||
|
||||
@@ -30,7 +31,7 @@ Low priority:
|
||||
- support for exception propagation? (hard to implement)
|
||||
- the copying of the 'ref Promise' into the thead local storage only
|
||||
happens to work due to the write barrier's implementation
|
||||
- implement lock levels --> first without the more complex race avoidance
|
||||
- implement lock levels
|
||||
|
||||
|
||||
Misc
|
||||
|
||||
Reference in New Issue
Block a user