diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2024-07-02 14:49:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-02 08:49:37 +0200 |
commit | fe3039410f9fa637fdd958df4d96272484ebdb86 (patch) | |
tree | d09e2a3a749bff15108473c5be4cae582384b31d /tests/discard/tdiscardable.nim | |
parent | 96aba18963cbcf87250f93b453122d411aeb1d17 (diff) | |
download | Nim-fe3039410f9fa637fdd958df4d96272484ebdb86.tar.gz |
fixes #23775; injectdestructors now handles discardable statements (#23780)
fixes #23775
Diffstat (limited to 'tests/discard/tdiscardable.nim')
-rw-r--r-- | tests/discard/tdiscardable.nim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/discard/tdiscardable.nim b/tests/discard/tdiscardable.nim index 5988f5949..31020251f 100644 --- a/tests/discard/tdiscardable.nim +++ b/tests/discard/tdiscardable.nim @@ -140,3 +140,27 @@ block: # issue #14665 continue inc i test() + +block: # bug #23775 + proc retInt(): int {.discardable.} = + 42 + + proc retString(): string {.discardable.} = + "text" + + type + Enum = enum + A, B, C, D + + proc doStuff(msg: Enum) = + case msg: + of A: + retString() + of B: + retInt() + of C: + discard retString() + else: + let _ = retString() + + doStuff(C) |