I have this code:
include karax/prelude
import components/main
proc test(): Vnode =
text("helo")
proc router(data: RouterData): VNode =
buildHtml(tdiv):
if data.hashPart == "#/":
test
setRenderer(router)
but I get this error:
Error: type mismatch: got <proc (): VNode{.noSideEffect, gcsafe, locks: 0.}>
but expected one of:
proc add(parent, kid: VNode)
first type mismatch at position: 1
required type for parent: VNode
but expression 'test' is of type: proc (): VNode{.noSideEffect, gcsafe, locks: 0.}
proc add(result: var string; n: VNode; indent = 0; indWidth = 2)
first type mismatch at position: 1
required type for result: var string
but expression 'test' is of type: proc (): VNode{.noSideEffect, gcsafe, locks: 0.}
proc add(x: var cstring; y: cstring)
first type mismatch at position: 1
required type for x: var cstring
but expression 'test' is of type: proc (): VNode{.noSideEffect, gcsafe, locks: 0.}
proc add(x: var string; y: char)
first type mismatch at position: 1
required type for x: var string
but expression 'test' is of type: proc (): VNode{.noSideEffect, gcsafe, locks: 0.}
proc add(x: var string; y: cstring)
first type mismatch at position: 1
required type for x: var string
but expression 'test' is of type: proc (): VNode{.noSideEffect, gcsafe, locks: 0.}
proc add(x: var string; y: string)
first type mismatch at position: 1
required type for x: var string
but expression 'test' is of type: proc (): VNode{.noSideEffect, gcsafe, locks: 0.}
proc add[T](x: var seq[T]; y: openArray[T])
first type mismatch at position: 1
required type for x: var seq[T]
but expression 'test' is of type: proc (): VNode{.noSideEffect, gcsafe, locks: 0.}
proc add[T](x: var seq[T]; y: sink T)
first type mismatch at position: 1
required type for x: var seq[T]
but expression 'test' is of type: proc (): VNode{.noSideEffect, gcsafe, locks: 0.}
expression: add(test)
Any help?
ChatGPT answers this question very well. It would be good if the Nim development team cooperates with OpenAI in order to add nim syntax highlighting to ChatGPT. It's the only thing missing.
It also shows how there is potential to improve the compiler error messages, but runing such language model is very heavy, and relying on the ~cloud~ is not ideal either, so not something realistic now.