diff --git a/ast/base/Value.cpp b/ast/base/Value.cpp index 26df8bc03..24f851861 100644 --- a/ast/base/Value.cpp +++ b/ast/base/Value.cpp @@ -576,7 +576,7 @@ bool Value::requires_memcpy_ref_struct(BaseType* known_type) { const auto chain = as_access_chain_unsafe(); const auto id = as_identifier_unsafe(); if(kind == ValueKind::Identifier || (kind == ValueKind::AccessChain && chain->values.back()->as_func_call() == nullptr)) { - auto linked = known_type->get_direct_linked_node(); + auto linked = known_type->get_ref_or_linked_node(known_type->kind()); if (linked) { auto k = linked->kind(); if(k == ASTNodeKind::UnnamedStruct || k == ASTNodeKind::UnnamedUnion) { diff --git a/ast/statements/VarInit.cpp b/ast/statements/VarInit.cpp index 3b9efd379..f5a6e8f6b 100644 --- a/ast/statements/VarInit.cpp +++ b/ast/statements/VarInit.cpp @@ -87,7 +87,7 @@ void VarInitStatement::code_gen(Codegen &gen) { if(!dyn_obj_impl) { auto llvmType = llvm_type(gen); // is referencing another struct, that is non movable and must be mem copied into the pointer - llvm_ptr = gen.memcpy_ref_struct(known_type(), value, nullptr, llvmType); + llvm_ptr = gen.memcpy_ref_struct(create_value_type(gen.allocator), value, nullptr, llvmType); if (llvm_ptr) { return; } diff --git a/compiler/backend/LLVM.cpp b/compiler/backend/LLVM.cpp index 3dd6cfc14..9862c39c2 100644 --- a/compiler/backend/LLVM.cpp +++ b/compiler/backend/LLVM.cpp @@ -1018,7 +1018,7 @@ bool Codegen::requires_memcpy_ref_struct(BaseType* known_type, Value* value) { llvm::Value* Codegen::memcpy_ref_struct(BaseType* known_type, Value* value, llvm::Value* llvm_ptr, llvm::Type* type) { // const auto pure = known_type->pure_type(); - if(requires_memcpy_ref_struct(known_type, value)) { + if(requires_memcpy_ref_struct(known_type->pure_type(allocator), value)) { if(!llvm_ptr) { llvm_ptr = builder->CreateAlloca(type, nullptr); } diff --git a/lang/libs/std/unordered_map.ch b/lang/libs/std/unordered_map.ch index 6ecf543ba..53b4982b2 100644 --- a/lang/libs/std/unordered_map.ch +++ b/lang/libs/std/unordered_map.ch @@ -95,7 +95,7 @@ struct unordered_map { } // Insert the new node at the front of the chain - var newNode = malloc(sizeof(unordered_map_node)) as *mut unordered_map_node; + const newNode = malloc(sizeof(unordered_map_node)) as *mut unordered_map_node; newNode.key = key; newNode.value = value; newNode.next = table[index];