Skip to content

instantiationInfo inside nested template calls gives wrong lineno. #4128

@Parashurama

Description

@Parashurama

InstanciationInfo() gives the wrong line number inside nested template calls.
I remember seeing this behavior inside the stdlib especially when triggering assert on changing sequence size while iterating.
The issue appears to be even worse inside deeply nested templates.

Here is a test file to reproduce the issue.

type
    LineInfo = tuple[filename: string, line: int]

proc proc_impl(msgid: string; info: LineInfo) =
    echo(info.filename, "(", info.line, ") message: ", msgid)

template templ3*(msgid: string): expr =
    proc_impl(msgid, instantiationInfo())

template templ2*(msgid: string): expr =
    templ3(msgid)

template templ1*(msgid: string): expr =
    templ2(msgid)

proc main() =
    templ1("hello world!")

main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions