fixes semi-regression; discard check now skips nkHiddenSubConv (#23840)

follow up https://github.com/nim-lang/Nim/pull/23681

ref https://forum.nim-lang.org/t/11987
This commit is contained in:
ringabout
2024-07-16 13:37:33 +08:00
committed by GitHub
parent b7a275da1d
commit 648f82c2ed
2 changed files with 10 additions and 1 deletions

View File

@@ -135,7 +135,7 @@ const
skipForDiscardable = {nkStmtList, nkStmtListExpr,
nkOfBranch, nkElse, nkFinally, nkExceptBranch,
nkElifBranch, nkElifExpr, nkElseExpr, nkBlockStmt, nkBlockExpr,
nkHiddenStdConv, nkHiddenDeref}
nkHiddenStdConv, nkHiddenSubConv, nkHiddenDeref}
proc implicitlyDiscardable(n: PNode): bool =
# same traversal as endsInNoReturn

View File

@@ -164,3 +164,12 @@ block: # bug #23775
let _ = retString()
doStuff(C)
block:
proc test(): (int, int) {.discardable.} =
discard
if true:
test()
else:
quit()