new .redefine pragma for templates, warn on redefinition without it (#20211)
* test CI for template redefinitions * adapt asyncmacro * fix quote * fix again * try something else * revert * fix ioselectors_select, disable packages CI * adapt more tests & simplify * more * more * more * rename to redefine, warn on implicit redefinition * basic documentation [skip ci] * Update compiler/lineinfos.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
This commit is contained in:
parent
14656154ef
commit
d1d141b135
19 changed files with 85 additions and 25 deletions
|
|
@ -7050,6 +7050,22 @@ immediate pragma
|
|||
The immediate pragma is obsolete. See `Typed vs untyped parameters
|
||||
<#templates-typed-vs-untyped-parameters>`_.
|
||||
|
||||
redefine pragma
|
||||
---------------
|
||||
|
||||
Redefinition of template symbols with the same signature is allowed.
|
||||
This can be made explicit with the `redefine` pragma:
|
||||
|
||||
```nim
|
||||
template foo: int = 1
|
||||
echo foo() # 1
|
||||
template foo: int {.redefine.} = 2
|
||||
echo foo() # 2
|
||||
# warning: implicit redefinition of template
|
||||
template foo: int = 3
|
||||
```
|
||||
|
||||
This is mostly intended for macro generated code.
|
||||
|
||||
compilation option pragmas
|
||||
--------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue