Fix scope->elements iteration causing a few bugs in the doc-format

This commit is contained in:
gingerBill
2026-03-19 20:31:01 +00:00
parent 3fb430ceb7
commit 111bee6ecd
2 changed files with 17 additions and 9 deletions

View File

@@ -788,11 +788,17 @@ gb_internal bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us,
rw_mutex_lock(&scope->mutex);
defer (rw_mutex_unlock(&scope->mutex));
for (auto const &entry : scope->elements) {
Entity *decl = entry.value;
if (!is_entity_exported(decl, true)) continue;
u32 hash = entry.hash;
auto interned = scope->elements.keys[hash & (scope->elements.cap-1)];
for (u32 i = 0; i < scope->elements.cap; i++) {
if (!scope->elements.slots[i].hash) {
continue;
}
Entity *decl = scope->elements.slots[i].value;
if (!is_entity_exported(decl, true)) {
continue;
}
u32 hash = scope->elements.slots[i].hash;
auto interned = scope->elements.keys[i];
Entity *found = scope_insert_with_name(ctx->scope, interned, hash, decl);
if (found != nullptr) {

View File

@@ -1042,10 +1042,12 @@ gb_internal OdinDocArray<OdinDocScopeEntry> odin_doc_add_pkg_entries(OdinDocWrit
auto entries = array_make<OdinDocScopeEntry>(heap_allocator(), 0, w->entity_cache.count);
defer (array_free(&entries));
for (auto const &element : pkg->scope->elements) {
u32 hash = element.hash;
auto interned = pkg->scope->elements.keys[hash & (pkg->scope->elements.cap-1)];
Entity *e = element.value;
for (isize i = 0; i < pkg->scope->elements.cap; i++) {
if (!pkg->scope->elements.slots[i].hash) {
continue;
}
auto interned = pkg->scope->elements.keys[i];
Entity *e = pkg->scope->elements.slots[i].value;
switch (e->kind) {
case Entity_Invalid:
case Entity_Nil: