type Example* = object
      str: string
      code: int
    
    proc x0(s: string): int = s.len
    
    proc x1(b: bool): Example =
      var x = "abc"
      if b:
        return Example(str: move x, code: x0(x))
      else:
        return Example(str: "...")
    
    echo x1(true)
    echo x1(false)
    
    
    Run

In a more complex code, this created a segfault when I tried to access 
Example.str

Reply via email to