Skip to content

Commit

Permalink
closes #16331; add testcase (#20730)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout authored Nov 2, 2022
1 parent 58f79e7 commit 841d9d5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/tuples/ttuples_issues.nim
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ template main() =
return (x,y)
doAssert bar() == (10, (11,))

block: # bug #16331
type T1 = tuple[a, b: int]

proc p(b: bool): T1 =
var x: T1 = (10, 20)
x = if b: (x.b, x.a) else: (-x.b, -x.a)
x

doAssert p(false) == (-20, -10)
doAssert p(true) == (20, 10)


proc mainProc() =
# other tests should be in `main`
block:
Expand Down

0 comments on commit 841d9d5

Please sign in to comment.