mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
* add test * improve test * progress * fix #14014 * fix bug Co-authored-by: cooldome <ariabushenko@bk.ru>
This commit is contained in:
@@ -201,8 +201,11 @@ proc setupArgsForConcurrency(g: ModuleGraph; n: PNode; objType: PType;
|
||||
# we pick n's type here, which hopefully is 'tyArray' and not
|
||||
# 'tyOpenArray':
|
||||
var argType = n[i].typ.skipTypes(abstractInst)
|
||||
if i < formals.len and formals[i].typ.kind in {tyVar, tyLent}:
|
||||
localError(g.config, n[i].info, "'spawn'ed function cannot have a 'var' parameter")
|
||||
if i < formals.len:
|
||||
if formals[i].typ.kind in {tyVar, tyLent}:
|
||||
localError(g.config, n[i].info, "'spawn'ed function cannot have a 'var' parameter")
|
||||
if formals[i].typ.kind in {tyTypeDesc, tyStatic}:
|
||||
continue
|
||||
#elif containsTyRef(argType):
|
||||
# localError(n[i].info, "'spawn'ed function cannot refer to 'ref'/closure")
|
||||
|
||||
@@ -226,6 +229,8 @@ proc setupArgsForParallelism(g: ModuleGraph; n: PNode; objType: PType;
|
||||
# for correctness: These are called 'threadLocal' here.
|
||||
for i in 1..<n.len:
|
||||
let n = n[i]
|
||||
if i < formals.len and formals[i].typ.kind in {tyStatic, tyTypeDesc}:
|
||||
continue
|
||||
let argType = skipTypes(if i < formals.len: formals[i].typ else: n.typ,
|
||||
abstractInst)
|
||||
#if containsTyRef(argType):
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
discard """
|
||||
output: '''4
|
||||
8'''
|
||||
8
|
||||
(a: 1)
|
||||
2
|
||||
2
|
||||
'''
|
||||
cmd: "nim $target --threads:on $options $file"
|
||||
"""
|
||||
|
||||
@@ -29,3 +33,32 @@ sync()
|
||||
|
||||
echo x
|
||||
echo y
|
||||
|
||||
|
||||
#--------------------------------------------------------
|
||||
# issue #14014
|
||||
|
||||
import threadpool
|
||||
|
||||
type A = object
|
||||
a: int
|
||||
|
||||
proc f(t: typedesc): t =
|
||||
t(a:1)
|
||||
|
||||
let r = spawn f(A)
|
||||
echo ^r
|
||||
|
||||
proc f2(x: static[int]): int =
|
||||
x
|
||||
|
||||
let r2 = spawn f2(2)
|
||||
echo ^r2
|
||||
|
||||
type statint = static[int]
|
||||
|
||||
proc f3(x: statint): int =
|
||||
x
|
||||
|
||||
let r3 = spawn f3(2)
|
||||
echo ^r3
|
||||
|
||||
Reference in New Issue
Block a user