Nim icon indicating copy to clipboard operation
Nim copied to clipboard

cannot return `lent` expression from conditionals like `case`

Open arnetheduck opened this issue 1 year ago • 2 comments
trafficstars

Description

type A = object
  field: int

proc works(a: A): lent int =
  a.field

proc x(a: A): lent int =
  case true
  of true:
    a.field
  of false:
    a.field

proc y(a: A): lent int =
  case true
  of true:
    a.field
  of false:
    raiseAssert "invalid"

Both x and y should have no problem returning the address of a.field to the consumer since they are equivalent to works - the address of the expression as a whole can be derived from the branches since the expressions therein have an address that readily can be used for this purpose.

Nim Version

2.0.8

Current Output

Error: expression has no address

Expected Output

No response

Possible Solution

No response

Additional Information

No response

arnetheduck avatar Aug 13 '24 11:08 arnetheduck