hades-lang icon indicating copy to clipboard operation
hades-lang copied to clipboard

Prevent move while aliased

Open dhruvrajvanshi opened this issue 2 years ago • 0 comments

def main(): Void {
    val x = 0

    if true {
        val y = &x

        val z = move x // Error: Move while aliased. y holds a live reference to x. Can't move it
    }
    val p = move x // fine, lifetime of alias has ended
}

dhruvrajvanshi avatar Oct 16 '22 20:10 dhruvrajvanshi