authorgravatar for dev@liujiacai.netJiacai Liu <dev@liujiacai.net> 2024-01-30 10:43:11+08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-01-29 21:43:11-05:00
log1b5cbf0d08d9d2fac1f17e4bcff916e4a179f080
tree533ab8dd5f258845574796f4b3879bca41ca13b7
parente460ba66a57f0a4e0ee07f32cef17c7f2bf290b4
signaturebadge-check Signed by PGP key B5690EEEBB952194

fix(autodoc): avoid panic when module not found (#18699)


1 files changed, 3 insertions(+), 1 deletions(-)

src/Autodoc.zig+3-1
...@@ -934,6 +934,8 @@ const AutodocErrors = error{...@@ -934,6 +934,8 @@ const AutodocErrors = error{
934 OutOfMemory,934 OutOfMemory,
935 CurrentWorkingDirectoryUnlinked,935 CurrentWorkingDirectoryUnlinked,
936 UnexpectedEndOfFile,936 UnexpectedEndOfFile,
937 ModuleNotFound,
938 ImportOutsideModulePath,
937} || std.fs.File.OpenError || std.fs.File.ReadError;939} || std.fs.File.OpenError || std.fs.File.ReadError;
938940
939/// `call` instructions will have loopy references to themselves941/// `call` instructions will have loopy references to themselves
...@@ -1058,7 +1060,7 @@ fn walkInstruction(...@@ -1058,7 +1060,7 @@ fn walkInstruction(
1058 );1060 );
1059 }1061 }
10601062
1061 const new_file = self.zcu.importFile(file, path) catch unreachable;1063 const new_file = try self.zcu.importFile(file, path);
1062 const result = try self.files.getOrPut(self.arena, new_file.file);1064 const result = try self.files.getOrPut(self.arena, new_file.file);
1063 if (result.found_existing) {1065 if (result.found_existing) {
1064 return DocData.WalkResult{1066 return DocData.WalkResult{