diff --git a/compiler/can/src/module.rs b/compiler/can/src/module.rs index 621ce9753e..89dfdea989 100644 --- a/compiler/can/src/module.rs +++ b/compiler/can/src/module.rs @@ -127,7 +127,7 @@ where } } - let (defs, scope1, output, symbols_introduced) = canonicalize_defs( + let (defs, _scope, output, symbols_introduced) = canonicalize_defs( &mut env, Output::default(), var_store, diff --git a/compiler/gen/src/llvm/build.rs b/compiler/gen/src/llvm/build.rs index 21502981ad..c7d806ef85 100644 --- a/compiler/gen/src/llvm/build.rs +++ b/compiler/gen/src/llvm/build.rs @@ -2245,10 +2245,29 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>( let (value, layout) = load_symbol_and_layout(scope, symbol); if layout.is_refcounted() { - if value.is_pointer_value() { - let value_ptr = value.into_pointer_value(); - let refcount_ptr = PointerToRefcount::from_ptr_to_data(env, value_ptr); - refcount_ptr.decrement(env, layout); + match value { + BasicValueEnum::PointerValue(value_ptr) => { + let refcount_ptr = + PointerToRefcount::from_ptr_to_data(env, value_ptr); + refcount_ptr.decrement(env, layout); + } + BasicValueEnum::StructValue(_value_struct) => { + match layout { + Layout::Builtin(Builtin::Str) + | Layout::Builtin(Builtin::List(_, _)) + | Layout::Builtin(Builtin::Dict(_, _)) + | Layout::Builtin(Builtin::Set(_)) => { + // let refcount_ptr = PointerToRefcount::from_list_wrapper(env, value_struct); + // refcount_ptr.decrement(env, layout); + eprintln!("we are likely leaking some memory, see #985 for details"); + } + _ => unreachable!( + "decref on weird type, likely a closure? {:?}", + layout + ), + } + } + _ => unreachable!("cannot be decref'd"), } }