Skip to content

push warning[Deprecated]: off doesn't work with templates #11805

@timotheecour

Description

@timotheecour

2 bugs:

  • push warning[Deprecated]: off doesn't work with templates;
  • the warnings get duplicated at each template call stack and need to be suppressed an equivalent number of times

Example

# lib.nim:
  proc foo2*() {.deprecated: "use foo2 instead".} = echo "ok1"

# main.nim:
  import ./lib
  template myfun*() =
    {.push warning[Deprecated]: off.}
    foo2()
    {.pop.}
  myfun()

Current Output

Warning: use foo2 instead; foo2 is deprecated [Deprecated]

Expected Output

no warning

Furthermore, if you remove the push/pop, you'll get 2 warnings instead of 1.

with double push it finally suppresses the warning:

  import ./lib
  {.push warning[Deprecated]: off.}
  template myfun*() =
    {.push warning[Deprecated]: off.}
    foo2()
    {.pop.}
  {.pop.}
  myfun()

but this isn't practical in more complex settings

Additional Information

  • Your Nim version (output of nim -v).
    latest devel f50e450
  • in my use case, I needed to suppress callsite deprecation warnings; callsite was needed for my use case (args: varargs[untyped] doesn't contain enough information)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions