carp-lang / carp-lang/Carp

Borrow checker is confused by using a match-ref with a let block

Open
#1,065 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug haskell memory
Dominant language
Haskell
Stars
6k
Forks
187
Avg merge
8d 22h
Merged PRs (30d)
4

Description

The following code produces a borrow checker error even though there is no shared values between the two match-ref:
```clojure
(deftype Sum One Two)

(defn main []
(do
(let []
(match-ref &(Sum.One)
Sum.One ()
Sum.Two ()))
(match-ref &(Sum.Two)
Sum.One ()
Sum.Two ())))
```

```
The reference '(ref (Sum.Two))' (depending on the variable '_9') isn't alive at line 9, column 15 in '/tmp/main.carp'. at /tmp/main.carp:3:1.
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by running the provided Carp reproduction and trace the borrow-checker path that reports the lifetime error; done means the example compiles without the false borrow error while preserving the behavior of both match-ref expressions.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.