--hintAsError (#16763)

* --hintAsError

* add test, changelog

* condsyms
This commit is contained in:
Timothee Cour 2021-01-20 01:49:59 -08:00 • committed by GitHub
commit 4fc7fcb775
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 56 additions and 9 deletions

View file

@ -0,0 +1,35 @@
discard """
joinable: false
"""
#[
tests: hintAsError, warningAsError
]#
template fn1 =
{.hintAsError[ConvFromXtoItselfNotNeeded]:on.}
proc fn(a: string) = discard a.string
{.hintAsError[ConvFromXtoItselfNotNeeded]:off.}
template fn2 =
{.hintAsError[ConvFromXtoItselfNotNeeded]:on.}
proc fn(a: string) = discard a
{.hintAsError[ConvFromXtoItselfNotNeeded]:off.}
template gn1 =
{.warningAsError[ProveInit]:on.}
proc fn(): var int = discard
discard fn()
{.warningAsError[ProveInit]:off.}
template gn2 =
{.warningAsError[ProveInit]:on.}
proc fn(): int = discard
discard fn()
{.warningAsError[ProveInit]:off.}
doAssert not compiles(fn1())
doAssert compiles(fn2())
doAssert not compiles(gn1())
doAssert compiles(gn2())