New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asyncmacro: Error: attempting to call undeclared routine: 'callback=', when using forward declaration #7124
Comments
so the problem is that you're not specifying the generic type to That error message is horrible though. |
For reference: https://forum.nim-lang.org/t/3493 |
As a side note, why is |
Uh? I always assumed |
99% of code uses this syntax. Why should it be removed? I never thought of |
I guess it probably is. But speaking from a user point of view it is just a type that is parametrized on another type, like every generic is. It seems arbitrary and inconsistent to use a special syntax just because it is a pointer |
@dom96 Could you paste the version of modulea that you got to work? I tried adding [T] to the call to sendMsgExternally(), and it still fails for me: # modulea
import asyncdispatch
import asyncnet
type
QueueID* = uint32
Msg*[T: not (ref|string|seq)] = object
content*: T
proc myQueue*(): QueueID =
QueueID(0)
proc sendMsgInternally[T](q: QueueID, m: ptr[Msg[T]]): void =
echo("Sending message internally to " & $q)
proc sendMsgExternally[T](q: QueueID, m: ptr[Msg[T]], size: uint32) {.async.}
proc sendMsg*[T](q: QueueID, m: ptr[Msg[T]]): void =
# fill m with data ...
if q == myQueue():
sendMsgInternally[T](q, m)
else:
let size = uint32(sizeof(Msg[T]))
asyncCheck sendMsgExternally[T](q, m, size)
proc sendMsgExternally[T](q: QueueID, m: ptr[Msg[T]], size: uint32) {.async.} =
echo("Sending message across the cluster to " & $q)
var sock = newAsyncSocket()
await sock.send(pointer(m), int(size)) FYI, I'm using thios version of Nim:
EDIT: And regarding ptr, I don't expect any syntax to be "removed", and I'll use whatever I have to, but I have to agree with @andreaferretti on this one; "ptr T" might be more "popular" (I wouldn't know), but "ptr[T]" is more "consistent", IMO. |
@skunkiferous apologies. That wasn't the proper fix. The real reason this fails is that the second module isn't importing
The ultimate goal is to remove the syntax, but we would have a deprecation path (as usual). I do really dislike that there are two syntaxes for this case, so I would like to discourage its use and eventually remove it from the language. |
As far as fixing this issue, I have a hunch that the async macro needs to "bind" the It would be nice to improve the error message as well. It took me far too long to work out the problem. |
@dom96 The import fixed that issue. Now I have so much more "other" errors to fix. :D But at least, I understand them. Regarding ptr, I'll rewrite my code accordingly; no point in using something that's deprecated (or soon going to be). |
Please, do leave |
I've checked open issues related to "callback", and could not find anthing similar, so I think it's a new issue. It's also been posted in the forum, in case someone knows a work-around.
It seems to be related mixing forward declarations with async code. Here is an example that causes the issue. It has to be defined as two different modules, otherwise I could not produce the error.
The text was updated successfully, but these errors were encountered: