From ccd24ed58b6b494b66cfa43aad59ac19ad94c5b1 Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Sat, 9 Sep 2023 20:23:57 +0200 Subject: [PATCH] fix memory errors related to astgen_analyser --- src/DocumentStore.zig | 11 ----------- src/Server.zig | 6 +++--- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/DocumentStore.zig b/src/DocumentStore.zig index 755ae86ba7..8e68e8b591 100644 --- a/src/DocumentStore.zig +++ b/src/DocumentStore.zig @@ -310,17 +310,6 @@ pub fn refreshDocument(self: *DocumentStore, uri: Uri, new_text: [:0]const u8) ! const new_import_count = handle.import_uris.items.len; const new_cimport_count = handle.cimports.len; - if (handle.root_decl.unwrap()) |decl_index| { - self.mod.?.destroyDecl(decl_index); - handle.root_decl = .none; - } - if (self.config.analysis_backend == .astgen_analyser and - handle.zir_status == .done and // TODO support oudated - !handle.zir.hasCompileErrors()) - { - try self.mod.?.semaFile(handle); - } - if (old_import_count != new_import_count or old_cimport_count != new_cimport_count) { diff --git a/src/Server.zig b/src/Server.zig index b6878f9462..cfce36fd06 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -862,8 +862,9 @@ pub fn updateConfiguration(server: *Server, new_config: configuration.Configurat if (new_zig_exe_path or new_zig_lib_path) { server.document_store.cimports.clearAndFree(server.document_store.allocator); } - - if (server.config.analysis_backend == .astgen_analyser) { + + if (server.config.analysis_backend == .astgen_analyser) blk: { + if (server.mod != null) break :blk; server.mod = Module.init(server.allocator, &server.ip, &server.document_store); server.document_store.mod = &server.mod.?; } else if (server.mod) |*mod| { @@ -887,7 +888,6 @@ pub fn updateConfiguration(server: *Server, new_config: configuration.Configurat server.allocator.free(json_message); } - // <----------------------------------------------------------> // don't modify config options after here, only show messages // <---------------------------------------------------------->