Nim icon indicating copy to clipboard operation
Nim copied to clipboard

Overloaded template causes `untyped` param is resolved when called.

Open litlighilit opened this issue 8 months ago • 6 comments

Description

If a template with untyped params is overloaded, then when the variant with untyped param is called, such a argument (symbol) will be resolved there.

template t(n: float) = discard
template t(todecl: untyped, x: int) =
  discard  # or: let todecl = x

t(ii, 3)   # <-  here `ii` is resolved.

In addition, either of the followings compiles without mistake:

template t(todecl: untyped, x: int) = discard
template t(todecl: untyped, n: char) = discard
t(ii, 3)  # ✓ works

Or

template t(todecl: untyped, x: int) = discard
t(ii, 3)   # ✓ works

Nim Version

Nim Compiler Version 2.1.1 [Windows: amd64] Compiled at 2024-04-27 Copyright (c) 2006-2024 by Andreas Rumpf

active boot switches: -d:release

Current Output

Error: undeclared identifier: 'ii'

Expected Output

(None)

Possible Solution

No response

Additional Information

So does for macro, proc, etc.

litlighilit avatar May 30 '24 13:05 litlighilit