diff --git a/src/compiler.pr b/src/compiler.pr index 3a3c6aa8..a09e1f72 100644 --- a/src/compiler.pr +++ b/src/compiler.pr @@ -1427,10 +1427,10 @@ def convert_ref_to_ref(tpe: &typechecking::Type, value: Value, loc: &Value, stat // Convert weak ref to strong reference // Need to check the ref count and return a null reference if its 0 - if is_weak_ref(tpe) and is_ref(value.tpe) { + if is_weak_ref(value.tpe) and is_ref(tpe) { let meta = state.load(ref_meta, extract1_ret, loc) let refcount = state.extract_value(builtins::int64_, meta, [0], loc) - let iszero = state.icmp(CompareInt::ule, refcount, + let iszero = state.icmp(CompareInt::sle, refcount, [ kind = ValueKind::INT, tpe = builtins::int64_, i = 0 ] !Value, loc) let res = state.alloca(value.tpe, loc) @@ -1463,7 +1463,7 @@ def convert_ref_to_ref(tpe: &typechecking::Type, value: Value, loc: &Value, stat br_to_end.value.br_unc.label_ = end push_label(end, state) - return state.load(value.tpe, res, loc) + return state.load(tpe, res, loc) } let start = [ kind = ValueKind::UNDEF, tpe = tpe ] !Value @@ -8499,7 +8499,7 @@ def create_destructor(tpe: &typechecking::Type, value: Value, state: &State) { } let ref_count_i8_ptr = state.bitcast(pointer(builtins::int8_), ref_count) - state.call("free", null, [ref_count_i8_ptr]) + //state.call("free", null, [ref_count_i8_ptr]) value = state.extract_value(pointer(tpe.tpe.tpe), ref, [1])