ormin icon indicating copy to clipboard operation
ormin copied to clipboard

type expected, but got: nil

Open kidandcat opened this issue 6 years ago • 4 comments

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)

kidandcat avatar Oct 27 '19 16:10 kidandcat

Is that a documentation/example bug?

Araq avatar Oct 28 '19 11:10 Araq

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.

kidandcat avatar Oct 28 '19 12:10 kidandcat

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

Araq avatar Oct 28 '19 12:10 Araq

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 ].

Araq avatar Oct 28 '19 14:10 Araq