diff options
-rw-r--r-- | compiler/semexprs.nim | 7 | ||||
-rw-r--r-- | nimsuggest/tests/tchk_compiles.nim | 8 |
2 files changed, 15 insertions, 0 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index c5b864d1f..72d407cf7 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -2062,6 +2062,10 @@ proc semQuoteAst(c: PContext, n: PNode): PNode = proc tryExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode = # watch out, hacks ahead: + 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 let oldErrorCount = c.config.errorCounter let oldErrorMax = c.config.errorMax let oldCompilesId = c.compilesContextId @@ -2111,6 +2115,9 @@ proc tryExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode = c.config.m.errorOutputs = oldErrorOutputs c.config.errorCounter = oldErrorCount c.config.errorMax = oldErrorMax + when defined(nimsuggest): + # Restore the error hook + c.graph.config.structuredErrorHook = tempHook proc semCompiles(c: PContext, n: PNode, flags: TExprFlags): PNode = # we replace this node by a 'true' or 'false' node: diff --git a/nimsuggest/tests/tchk_compiles.nim b/nimsuggest/tests/tchk_compiles.nim new file mode 100644 index 000000000..887a947b5 --- /dev/null +++ b/nimsuggest/tests/tchk_compiles.nim @@ -0,0 +1,8 @@ +discard compiles(2 + "hello") + +#[!]# +discard """ +$nimsuggest --tester $file +>chk $1 +chk;;skUnknown;;;;Hint;;???;;0;;-1;;"tchk_compiles [Processing]";;0 +""" |