Skip to content

Commit

Permalink
fixes semi-regression; discard check now skips nkHiddenSubConv (#23840
Browse files Browse the repository at this point in the history
)

follow up #23681

ref https://forum.nim-lang.org/t/11987

(cherry picked from commit 648f82c)
  • Loading branch information
ringabout authored and narimiran committed Aug 31, 2024
1 parent 8b421d2 commit 568a637
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/semstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/discard/tdiscardable.nim
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,12 @@ block: # issue #14665
continue
inc i
test()

block:
proc test(): (int, int) {.discardable.} =
discard

if true:
test()
else:
quit()

0 comments on commit 568a637

Please sign in to comment.