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

(cherry picked from commit 648f82c2ed)
This commit is contained in:
ringabout
2024-07-16 13:37:33 +08:00
committed by narimiran
parent 8b421d2203
commit 568a637f0f
2 changed files with 10 additions and 1 deletions

View File

@@ -132,7 +132,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

@@ -140,3 +140,12 @@ block: # issue #14665
continue
inc i
test()
block:
proc test(): (int, int) {.discardable.} =
discard
if true:
test()
else:
quit()