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

[pull] master from carp-lang:master #15

Merged
merged 1 commit into from
Apr 11, 2022
Merged

Conversation

pull[bot]
Copy link

@pull pull bot commented Apr 11, 2022

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

* fix: respect let binding shadowing in memory management

Previously, we didn't account for shadowing in let bindings in our
memory management routines. This led to rare situations in which
multiple deleters might be added for a single variable name, for
example:

```clojure
(defn n [xs]
  (let [xs [1 2 3]
        n &xs]
    n))
```

The borrow checker would fail on this code since it would assign `xs`
two deleters, one for the untyped argument and another for the let
binding.

Instead, we now perform *exclusive* ownership transfer for the duration
of the let scope--when a shadow is introduced, the previous deleters for
that variable name are dropped until the end of the let scope, since we
evaluate all instances of the shadowed name to the more local binding.
At the end of the let scope, the original deleter is restored.

Fixes issue #597

* refactor: improved dead reference error for let

Since let scopes resolve to their bodies, we can report the body of the
let as the xobj producing an error when a dead reference is returned.

* test: update error message for dead refs in let

* test: add regression test for issue #597

Ensure we don't regress and fail to manage memory when let bindings
shadow function argument names.
@pull pull bot added the ⤵️ pull label Apr 11, 2022
@pull pull bot merged commit fa8af08 into forksnd:master Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant