Skip to content

Implicit copy of pinned kind runs destructor twice #985

Closed
@brson

Description

@brson
resource r(i: @mutable int) {
    *i = *i + 1;
}

fn movearg(i: r) {
    // Implicit copy to mutate reference i
    let j <- i;
}

fn main() {
    let i = @mutable 0;
    {
        let j <- r(i);
        movearg(j);
    }
    log_err *i;
    // nooooooo. destructor ran twice
    assert *i == 2;
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions