; Fieldtest cut55-4 — decision (d), borrow-return rejected at the signature.
;
; An author who wants "give me a view of the first element without taking
; ownership" might try to declare the RETURN as a borrow:
;   (ret (borrow (con List)))
; Per the ledger a borrow may not escape into a return; `borrow-return` is
; rejected at the signature. I expect a clear error that tells me the
; return cannot be a borrow (and, ideally, to clone or return own).
;
; Expected: ail check -> error [borrow-return], exit 1.

(module cut55_4_borrow_return_reject

  (data List
    (ctor Nil)
    (ctor Cons (con Int) (con List)))

  (fn tail_view
    (doc "Try to return a borrowed view of the tail — illegal escape.")
    (type
      (fn-type
        (params (borrow (con List)))
        (ret (borrow (con List)))))
    (params xs)
    (body
      (match xs
        (case (pat-ctor Nil) xs)
        (case (pat-ctor Cons h t) t)))))
