Nim: Unexpected import required

Created on 30 Apr 2018  路  4Comments  路  Source: nim-lang/Nim

Building this program:

import xmltree

type
        Drawing* = tuple[fname: string, document: XmlNode]

proc NewDrawing*(fname: string, height:string="100", width:string="100"): Drawing =
        result = (
            fname: fname,
            document: <>svg(width=width, height=height)
        )

when isMainModule:
        var d = NewDrawing("foo.svg")

Fails with this error:

svg1.nim(9, 19) template/generic instantiation from here
lib/nim/core/macros.nim(556, 26) Error: undeclared identifier: 'newStringTable'

This is with both git HEAD and with latest release:

nim --version                                           
Nim Compiler Version 0.18.1 [Linux: amd64]
Copyright (c) 2006-2018 by Andreas Rumpf

git hash: 9d77f61038ddabeb4b59847d709e6d722e743082
active boot switches: -d:release -d:nativeStackTrace
Easy Stdlib

Most helpful comment

I know how to work around it. I wrote a blog post about this and @nim-lang on twitter told me to report the bug.

All 4 comments

Just add strtabs to import.

This is due to the macro pasting newStringTable at the instantiation site (contrary to proc). You can work around it by adding strtabs like data-man said.

I think xmltree should at least export this proc though or call it internally in a proc and not a macro to avoid this issue.

I know how to work around it. I wrote a blog post about this and @nim-lang on twitter told me to report the bug.

@Araq
May I fix it?
Also, StringTable returned as result in the modules:
scgi.nim
mimetypes.nim
smtp.nim
xmlparser.nim
htmlparser.nim
cgi.nim
cookies.nim
httpserver.nim

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kobi2187 picture kobi2187  路  4Comments

capocasa picture capocasa  路  3Comments

koki-koba picture koki-koba  路  3Comments

alaviss picture alaviss  路  3Comments

hlaaftana picture hlaaftana  路  3Comments