Problem with sets in devel #4412

Closed
flyx opened this Issue Jun 26, 2016 · 2 comments

Projects

None yet

2 participants

@flyx
Contributor
flyx commented Jun 26, 2016 edited
import jester, asyncdispatch, emerald

proc index(content: string) {.html_templ.} =
  html(lang = "en"):
    head:
      title: "Index"
    body:
      put content

routes:
  get "/":
    var
      s = newStringStream()
      templ = newIndex()
    templ.content = "Hello, world!"
    templ.render(s)
    resp s.data

runForever()

Needs current git master from jester, as latest nimble version does not work with Nim 0.14.x. emerald is the latest nimble version. This code produces the following error:

lib/pure/collections/sets.nim(282, 43) Error: cannot generate VM code for type(s.data[i].key)

Works with 0.14.2.

@flyx flyx referenced this issue in flyx/emerald Jun 26, 2016
Open

Usage in Jester? #6

@mbaulch
Contributor
mbaulch commented Jul 5, 2016

It looks like 5f83e86 caused the issue.

@mbaulch
Contributor
mbaulch commented Jul 6, 2016

The compile-time VM doesn't fully implement the Nim language. Some features are missing. I think the change to collections/sets (noted above) adds reliance on compile-time only features. Specifically, the limitations of type introspection.

To illustrate the issue with a smaller (and less macro-laden) example, consider

proc default[T](t: typedesc[T]): T {.inline.} = discard

static:
  var x = default(type(0))

which gives:

test.nim(4, 24) Error: cannot generate VM code for type(0)

For an example of similar code that compiles, consider:

proc default[T](t: typedesc[T]): T {.inline.} = discard

static:
  var x: type(0)
  var y = default(int)
@Araq Araq closed this in 09783c3 Jul 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment