Skip to content
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

type expected, but got: nil #19

Open
kidandcat opened this issue Oct 27, 2019 · 4 comments
Open

type expected, but got: nil #19

kidandcat opened this issue Oct 27, 2019 · 4 comments

Comments

@kidandcat
Copy link

kidandcat commented Oct 27, 2019

import ormin / [serverws]
import ormin

import json

importModel(DbBackend.sqlite, "chat_model")

#var db {.global.} = open("chat_ormin.db", "", "", "")

protocol "pingclient.nim":
  server "ping":
    echo "got ping"
    send(%1)

  client "ping":
    proc ping*() {.exportc.}
    var res: int
    res = recv()
    echo "got " & $res

serve "ormin", dispatch

In the chat example you don't specify the type to recv()

PD: it works if I use recv(int)

@Araq
Copy link
Owner

Araq commented Oct 28, 2019

Is that a documentation/example bug?

@kidandcat
Copy link
Author

kidandcat commented Oct 28, 2019

I suppose yes, but if you tell me it should work without the typing.... I'm not sure if recv() can infer the type from the variable you are assigning to.

If it's a doc bug, I'll fix it by PR.

@Araq
Copy link
Owner

Araq commented Oct 28, 2019

Hmm, I don't remember Ormin's code base. :D Stay tuned.

@Araq
Copy link
Owner

Araq commented Oct 28, 2019

So ... forumproto.nim contains this code:

  client:
    type Session = ref object
    var gSessions: seq[Session]
    gSessions = recv()
    proc getAllSessions()

And to the best of my knowledge this test is green. recv() here uses the seq[ of the previously type as defined in the type section ].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants