Skip to content

Double moves out of arrays are allowed #14986

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

Closed
zwarich opened this issue Jun 17, 2014 · 0 comments
Closed

Double moves out of arrays are allowed #14986

zwarich opened this issue Jun 17, 2014 · 0 comments
Labels
A-type-system Area: Type system

Comments

@zwarich
Copy link

zwarich commented Jun 17, 2014

This program is accepted, but it shouldn't be:

fn f(mut a: [Box<int>, ..2]) {
    drop(a[0]);
    a[1] = box 2;
    drop(a[0]);
}

fn main() {
    f([box 0, box 1]);
}

The problem is that array paths do not incorporate the index, and thus do not refer to a unique location, unlike other LoanPaths. Strong updates to kill previous moves are only valid for paths that refer to a unique location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants