mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
* fix #22448 * add test
This commit is contained in:
@@ -353,6 +353,11 @@ proc tryConstExpr(c: PContext, n: PNode; expectedType: PType = nil): PNode =
|
||||
c.config.m.errorOutputs = {}
|
||||
c.config.errorMax = high(int) # `setErrorMaxHighMaybe` not appropriate here
|
||||
|
||||
when defined(nimsuggest):
|
||||
# Remove the error hook so nimsuggest doesn't report errors there
|
||||
let tempHook = c.graph.config.structuredErrorHook
|
||||
c.graph.config.structuredErrorHook = nil
|
||||
|
||||
try:
|
||||
result = evalConstExpr(c.module, c.idgen, c.graph, e)
|
||||
if result == nil or result.kind == nkEmpty:
|
||||
@@ -363,6 +368,10 @@ proc tryConstExpr(c: PContext, n: PNode; expectedType: PType = nil): PNode =
|
||||
except ERecoverableError:
|
||||
result = nil
|
||||
|
||||
when defined(nimsuggest):
|
||||
# Restore the error hook
|
||||
c.graph.config.structuredErrorHook = tempHook
|
||||
|
||||
c.config.errorCounter = oldErrorCount
|
||||
c.config.errorMax = oldErrorMax
|
||||
c.config.m.errorOutputs = oldErrorOutputs
|
||||
|
||||
11
nimsuggest/tests/t22448.nim
Normal file
11
nimsuggest/tests/t22448.nim
Normal file
@@ -0,0 +1,11 @@
|
||||
proc fn(a: static float) = discard
|
||||
proc fn(a: int) = discard
|
||||
|
||||
let x = 1
|
||||
fn(x)
|
||||
|
||||
discard """
|
||||
$nimsuggest --tester --v3 $file
|
||||
>chk $file
|
||||
chk;;skUnknown;;;;Hint;;*
|
||||
"""
|
||||
Reference in New Issue
Block a user