diff --git a/compiler/middle/explicit_move_copy.ts b/compiler/middle/explicit_move_copy.ts index ea9984c..533bec4 100644 --- a/compiler/middle/explicit_move_copy.ts +++ b/compiler/middle/explicit_move_copy.ts @@ -13,7 +13,7 @@ class LocalExpliciter { private copyable: boolean; public constructor(private fn: Fn, private local: Local) { - this.copyable = copyableIsType(local.vtype); + this.copyable = copyableIsType(this.local.vtype); } public pass() { @@ -23,7 +23,7 @@ class LocalExpliciter { } private explicitSrc(src: RValue): RValue { - if (src.type !== "local") { + if (src.type !== "local" || src.id !== this.local.id) { return src; } return this.copyable @@ -41,8 +41,10 @@ function copyableIsType(vtype: VType): boolean { case "int": case "bool": case "string": + return true; case "ref": case "ref_mut": + return false; case "ptr": case "ptr_mut": return true;