Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression on borrowchecker + match-ref + lambda #1395

Open
TimDeve opened this issue Mar 7, 2022 · 0 comments
Open

Regression on borrowchecker + match-ref + lambda #1395

TimDeve opened this issue Mar 7, 2022 · 0 comments
Labels
bug haskell memory Borrow checker and lifetimes

Comments

@TimDeve
Copy link
Contributor

TimDeve commented Mar 7, 2022

Using a match-ref within a lambda can confuse the borrow checker.

Example:

(deftype WorldState (Intro [Int]) (Outro [Int]))

(deftype World [state WorldState])

(defn main []
 (let [world (World (WorldState.Intro 13))
       f     (fn [wrld]
              (match-ref (World.state &wrld)
                 (WorldState.Intro tikin) (+ @tikin 13)
                 (WorldState.Outro tikout) (+ @tikout 13)
                 _                      0))]
   (f world)))

Outputs this error:

The reference 'tikout' (depending on the variable 'tikin') isn't alive at line 11, column 48 in '/.../main.carp'. at /.../main.carp:6:2.

Traceback:
  (defn main [] (let [world (World (WorldState.Intro 13)) f (f...) at /.../main.carp:6:1.

This seems to be a regression as this line used to compile.

@eriksvedang eriksvedang added bug memory Borrow checker and lifetimes haskell labels Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug haskell memory Borrow checker and lifetimes
Projects
None yet
Development

No branches or pull requests

2 participants