pragmagic / vscode-nim

An extension for VS Code which provides support for the Nim language.
Other
238 stars 37 forks source link

tables.toOrderedTable marked as error when dom imported #143

Open ghost opened 4 years ago

ghost commented 4 years ago

Just reporting a small quirk: In the code below, toOrderedTable is marked as an error with the message:

template/generic instantiation of toOrderedTable from here found 'initImpl' of kind 'unknown'

However, it compiles without any issues. Because I moved the rendering code to another file, I removed the dom import and the error marking disappeared. I tried reinserting the import to see what would happen and the error returned, but if I move dom to the end of the import list, the error disappears again. So it's a small thing - maybe I missed some documentation on how to order imports - but it might be confusing to a new user.

import dom, tables, json, strformat
import ../../renderers/rnd_record_view

proc countryRecord*(country: JsonNode) =
    var recordView: RecordView = (
        recordTitle: "",
        groups: @[]
    )

    proc renderCountryRecord(record: RecordGroup): string =
        let fields = record.rows
        result = fmt"""
            <div class="record-row">
                <div class="record-value">{fields["country"].value}</div>
                <div class="record-label">{fields["country"].label}</div>
            </div>
        """

    let countryGroup: RecordGroup = (
        title: "",
        rows: {
            "country": (label: "Country", value: country["name"].getStr)
        }.toOrderedTable
    )

    recordView.groups.add(countryGroup)
    recordView.render(renderCountryRecord)