summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-07-16 13:37:33 +0800
committerGitHub <noreply@github.com>2024-07-16 07:37:33 +0200
commit648f82c2edbf34c1a8d9df464fa0987accce3b03 (patch)
tree573a2eb769631e96f573a60950e467e12cc1093b
parentb7a275da1dc4b454d81b3ba0fa58d2a742285f7b (diff)
downloadNim-648f82c2edbf34c1a8d9df464fa0987accce3b03.tar.gz
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
-rw-r--r--compiler/semstmts.nim2
-rw-r--r--tests/discard/tdiscardable.nim9
2 files changed, 10 insertions, 1 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index bb34d8a64..915f2dcb6 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -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
diff --git a/tests/discard/tdiscardable.nim b/tests/discard/tdiscardable.nim
index 31020251f..84b669ed8 100644
--- a/tests/discard/tdiscardable.nim
+++ b/tests/discard/tdiscardable.nim
@@ -164,3 +164,12 @@ block: # bug #23775
       let _ = retString()
 
   doStuff(C)
+
+block:
+  proc test(): (int, int) {.discardable.} =
+    discard
+
+  if true:
+    test()
+  else:
+    quit()