Fix compiles for nimsuggest [backport] (#14527)
* Handle nimsuggest in tryExpr * Added test
This commit is contained in:
parent
5900d8442c
commit
00ec43305e
2 changed files with 15 additions and 0 deletions
|
|
@ -2062,6 +2062,10 @@ proc semQuoteAst(c: PContext, n: PNode): PNode =
|
||||||
|
|
||||||
proc tryExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
proc tryExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||||
# watch out, hacks ahead:
|
# 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 oldErrorCount = c.config.errorCounter
|
||||||
let oldErrorMax = c.config.errorMax
|
let oldErrorMax = c.config.errorMax
|
||||||
let oldCompilesId = c.compilesContextId
|
let oldCompilesId = c.compilesContextId
|
||||||
|
|
@ -2111,6 +2115,9 @@ proc tryExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||||
c.config.m.errorOutputs = oldErrorOutputs
|
c.config.m.errorOutputs = oldErrorOutputs
|
||||||
c.config.errorCounter = oldErrorCount
|
c.config.errorCounter = oldErrorCount
|
||||||
c.config.errorMax = oldErrorMax
|
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 =
|
proc semCompiles(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
# we replace this node by a 'true' or 'false' node:
|
# we replace this node by a 'true' or 'false' node:
|
||||||
|
|
|
||||||
8
nimsuggest/tests/tchk_compiles.nim
Normal file
8
nimsuggest/tests/tchk_compiles.nim
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
discard compiles(2 + "hello")
|
||||||
|
|
||||||
|
#[!]#
|
||||||
|
discard """
|
||||||
|
$nimsuggest --tester $file
|
||||||
|
>chk $1
|
||||||
|
chk;;skUnknown;;;;Hint;;???;;0;;-1;;"tchk_compiles [Processing]";;0
|
||||||
|
"""
|
||||||
Loading…
Add table
Add a link
Reference in a new issue