From 4fc7fcb775140dc774a713063917fbf7d1392bdf Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Wed, 20 Jan 2021 01:49:59 -0800 Subject: `--hintAsError` (#16763) * --hintAsError * add test, changelog * condsyms --- tests/misc/twarningaserror.nim | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/misc/twarningaserror.nim (limited to 'tests') diff --git a/tests/misc/twarningaserror.nim b/tests/misc/twarningaserror.nim new file mode 100644 index 000000000..6f7b76095 --- /dev/null +++ b/tests/misc/twarningaserror.nim @@ -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()) -- cgit 1.4.1-2-gfad0