fix explicit copy move

This commit is contained in:
sfja 2025-01-18 09:00:13 +01:00
parent 5d6b1abefc
commit 9cb145d97e

View File

@ -13,7 +13,7 @@ class LocalExpliciter {
private copyable: boolean; private copyable: boolean;
public constructor(private fn: Fn, private local: Local) { public constructor(private fn: Fn, private local: Local) {
this.copyable = copyableIsType(local.vtype); this.copyable = copyableIsType(this.local.vtype);
} }
public pass() { public pass() {
@ -23,7 +23,7 @@ class LocalExpliciter {
} }
private explicitSrc(src: RValue): RValue { private explicitSrc(src: RValue): RValue {
if (src.type !== "local") { if (src.type !== "local" || src.id !== this.local.id) {
return src; return src;
} }
return this.copyable return this.copyable
@ -41,8 +41,10 @@ function copyableIsType(vtype: VType): boolean {
case "int": case "int":
case "bool": case "bool":
case "string": case "string":
return true;
case "ref": case "ref":
case "ref_mut": case "ref_mut":
return false;
case "ptr": case "ptr":
case "ptr_mut": case "ptr_mut":
return true; return true;