diff --git a/src/docs_writer.cpp b/src/docs_writer.cpp index 7a12d0875..67d350f24 100644 --- a/src/docs_writer.cpp +++ b/src/docs_writer.cpp @@ -265,8 +265,12 @@ gb_internal OdinDocPosition odin_doc_token_pos_cast(OdinDocWriter *w, TokenPos c AstFile *file = global_files[pos.file_id]; if (file != nullptr) { OdinDocFileIndex *file_index_found = map_get(&w->file_cache, file); - GB_ASSERT(file_index_found != nullptr); - file_index = *file_index_found; + // NOTE: a documented entity may hold a position in a file belonging to an + // imported package. Such files are only in file_cache when -all-packages is + // used, so fall back to the reserved "no file" index. + if (file_index_found != nullptr) { + file_index = *file_index_found; + } } }