make tok stable under multi-thread

This commit is contained in:
kalsprite
2026-08-07 15:58:25 -07:00
parent e140512954
commit 391a862e4f

View File

@@ -2050,18 +2050,26 @@ gb_internal bool redeclaration_error(String name, Entity *prev, Entity *found) {
// NOTE(bill): Error should have been handled already
return false;
}
// NOTE: the insertion order is a race between the files of a package, so anchor on the
// lower position to keep the diagnostic stable
TokenPos lo = prev->token.pos;
TokenPos hi = pos;
if (hi < lo) {
lo = pos;
hi = prev->token.pos;
}
if (found->flags & EntityFlag_Result) {
error(prev->token,
error(lo,
"Direct shadowing of the named return value '%.*s' in this scope\n"
"\tat %s",
LIT(name),
token_pos_to_string(pos));
token_pos_to_string(hi));
} else {
error(prev->token,
error(lo,
"Redeclaration of '%.*s' in this scope\n"
"\tat %s",
LIT(name),
token_pos_to_string(pos));
token_pos_to_string(hi));
}
}
return false;