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

Unhandled and undesired borrow error #31

Open
timfennis opened this issue Nov 15, 2024 · 1 comment
Open

Unhandled and undesired borrow error #31

timfennis opened this issue Nov 15, 2024 · 1 comment
Labels
bug Something isn't working error message An error message was unclear or incorrect

Comments

@timfennis
Copy link
Owner

let x = 0
let g = fn(a, b) { print(x); a + b }
x g= 3

outputs:

thread 'main' panicked at src/interpreter/environment.rs:154:20:
already mutably borrowed: BorrowError
@timfennis timfennis added bug Something isn't working error message An error message was unclear or incorrect labels Nov 15, 2024
@timfennis
Copy link
Owner Author

timfennis commented Nov 30, 2024

Attempted a bad fix but it's probably not going to work.

The problem is that evaluating g wants to borrow x when printing, but it also hold a mutable borrow to x. I fixed this implementation but there are also implication for this case.

let x = %{0: 0};
let g = fn(a, b) { print(x); a + b };
x[0] g= 3;

which errors like this:

thread 'main' panicked at src/interpreter/sequence.rs:89:33:
already mutably borrowed: BorrowError
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working error message An error message was unclear or incorrect
Projects
None yet
Development

No branches or pull requests

1 participant