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:
metagn 2022-08-23 22:41:30 +03:00 • committed by GitHub
commit d1d141b135
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 85 additions and 25 deletions

View file

@ -691,6 +691,9 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
if proto == nil:
addInterfaceOverloadableSymAt(c, c.currentScope, s)
elif not comesFromShadowscope:
if {sfTemplateRedefinition, sfGenSym} * s.flags == {}:
#wrongRedefinition(c, n.info, proto.name.s, proto.info)
message(c.config, n.info, warnTemplateRedefinition, s.name.s)
symTabReplace(c.currentScope.symbols, proto, s)
if n[patternPos].kind != nkEmpty:
c.patterns.add(s)