fixes #23949; cannot return lent expression from conditionals like case (#25190)

fixes #23949

It can also allow  `endsInNoReturn` in branches later
This commit is contained in:
ringabout
2025-09-24 12:29:57 +08:00
committed by GitHub
parent d85c0324b7
commit ceaa7fb4e8
2 changed files with 60 additions and 1 deletions

25
tests/lent/tlents.nim Normal file
View File

@@ -0,0 +1,25 @@
discard """
targets: "c cpp"
"""
type A = object
field: int
proc x(a: A): lent int =
result = case true
of true:
a.field
of false:
a.field
proc y(a: A): lent int =
result = if true:
a.field
else:
a.field
block:
var a = A(field: 1)
doAssert x(a) == 1
doAssert y(a) == 1