summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorDanil Yarantsev <tiberiumk12@gmail.com>2020-06-01 16:06:45 +0300
committerGitHub <noreply@github.com>2020-06-01 15:06:45 +0200
commit00ec43305e51c4b3c0fc4f288a775f90189a4a7c (patch)
treee890e9a49bf8efe3137c7a29bdf7348c22159e2e /compiler
parent5900d8442c6bf41bfaab02ae877ebf23680680bb (diff)
downloadNim-00ec43305e51c4b3c0fc4f288a775f90189a4a7c.tar.gz
Fix `compiles` for nimsuggest [backport] (#14527)
* Handle nimsuggest in tryExpr
* Added test
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semexprs.nim7
1 files changed, 7 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: