nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

missing `XDeclaredButNotUsed` hint #22139

Open tersec opened 1 year ago

tersec commented 1 year ago

Description

proc g(p: int)  = discard
proc g(p: bool) = discard
template f() = g(0)
f()
proc g(p: bool) = discard

is not used, but Nim does not display a XDeclaredButNotUsed hint.

Nim Version

Nim Compiler Version 1.9.5 [Linux: amd64]
Compiled at 2023-06-21
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: db41f04ab0734b0ac5267b46f306b0a311f7fc71
active boot switches: -d:release
Nim Compiler Version 1.6.10 [Linux: amd64]
Compiled at 2023-02-12
Copyright (c) 2006-2021 by Andreas Rumpf

active boot switches: -d:release

Current Output

No `XDeclaredButNotUsed` hint.

Expected Output

repro.nim(2, 6) Hint: 'g' is declared but not used [XDeclaredButNotUsed]

Possible Solution

No response

Additional Information

No response

metagn commented 1 year ago

Kind of intentional

https://github.com/nim-lang/Nim/blob/3ad2e7df1cfb0b454a96dbbc10b2684d1f53dc9b/compiler/semtempl.nim#L85

Added in https://github.com/nim-lang/Nim/commit/62aa8bed3b6472e8acae530f7014e7e5b0c755b5

Araq commented 1 year ago

It is used, the overloading means that inside f the g is a symchoice.