commit cd357fc7676a86b11a3593d63bd530add91cfd6e (tree)
parent d2baf404a550ea61402e2cba131168c6001e8dab
Author: Loris Cro <kappaloris@gmail.com>
Date: Wed, 8 Jun 2022 18:00:48 +0200
autodoc: fix package issue when analyzing stdlib
Diffstat:
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/Autodoc.zig b/src/Autodoc.zig
@@ -1032,12 +1032,18 @@ fn walkInstruction(
// Immediately add this package to the import table of our
// current package, regardless of wether it's new or not.
- const current_package = self.packages.getPtr(file.pkg).?;
- _ = try current_package.table.data.getOrPutValue(
- self.arena,
- path,
- self.packages.getIndex(other_package).?,
- );
+ if (self.packages.getPtr(file.pkg)) |current_package| {
+ // TODO: apparently, in the stdlib a file gets analized before
+ // its package gets added. I guess we're importing a file
+ // that belongs to another package through its file path?
+ // (ie not through its package name).
+ // We're bailing for now, but maybe we shouldn't?
+ _ = try current_package.table.data.getOrPutValue(
+ self.arena,
+ path,
+ self.packages.getIndex(other_package).?,
+ );
+ }
if (result.found_existing) {
return DocData.WalkResult{