mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-14 09:44:26 +00:00
Merge pull request #7253 from kalsprite/s575
Make redeclaration diagnostics stable under threading
This commit is contained in:
@@ -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 order the pair by
|
||||
// position; the later declaration stays the anchor, as it is the one being reported
|
||||
TokenPos first = prev->token.pos;
|
||||
TokenPos second = pos;
|
||||
if (second < first) {
|
||||
first = pos;
|
||||
second = prev->token.pos;
|
||||
}
|
||||
if (found->flags & EntityFlag_Result) {
|
||||
error(prev->token,
|
||||
error(second,
|
||||
"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(first));
|
||||
} else {
|
||||
error(prev->token,
|
||||
error(second,
|
||||
"Redeclaration of '%.*s' in this scope\n"
|
||||
"\tat %s",
|
||||
LIT(name),
|
||||
token_pos_to_string(pos));
|
||||
token_pos_to_string(first));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user