You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to pass a proc stored in an object does not compile.
Here is a minimal code example that triggers the issue.
import std/tasks
typeStore=object
run: proc (a: int) {.nimcall, gcsafe.}
prochello(a: int) =echo a
var store =Store()
store.run = hello
let b =toTask store.run(13)
b.invoke()
A workaround for this is to wrap the call in a proc that can avoid the dot notation.
For example, using the following lets it compile correctly.
procrunner(s: Store, n: int) =
store.run(n)
let b =toTaskrunner(store, 13)
Nim Version
Nim Compiler Version 2.1.1 [Windows: amd64]
Compiled at 2024-02-10
Copyright (c) 2006-2024 by Andreas Rumpf
active boot switches: -d:release
Current Output
C:\Users\_\.choosenim\toolchains\nim-#devel\lib\std\tasks.nim(124, 20) toTask
C:\Users\_\.choosenim\toolchains\nim-#devel\lib\std\effecttraits.nim(54, 3) isGcSafe
C:\Users\_\.choosenim\toolchains\nim-#devel\lib\core\macros.nim(689, 24) expectKind
d:\dump\Git\_\prep_tests\network_runner\code_format.nim(15, 21) Error: Expected a node of kind nnkSym, got nnkDotExpr
Expected Output
Compilation followed by "13"
Possible Solution
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Description
Trying to pass a proc stored in an object does not compile.
Here is a minimal code example that triggers the issue.
A workaround for this is to wrap the call in a proc that can avoid the dot notation.
For example, using the following lets it compile correctly.
Nim Version
Nim Compiler Version 2.1.1 [Windows: amd64]
Compiled at 2024-02-10
Copyright (c) 2006-2024 by Andreas Rumpf
active boot switches: -d:release
Current Output
Expected Output
Possible Solution
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: