From 00ec43305e51c4b3c0fc4f288a775f90189a4a7c Mon Sep 17 00:00:00 2001 From: Danil Yarantsev Date: Mon, 1 Jun 2020 16:06:45 +0300 Subject: Fix `compiles` for nimsuggest [backport] (#14527) * Handle nimsuggest in tryExpr * Added test --- compiler/semexprs.nim | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compiler') 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: -- cgit 1.4.1-2-gfad0