Incorrect visibility on local globals with public aliases. #2519

This commit is contained in:
Christoffer Lerno
2025-10-07 21:52:15 +02:00
parent 04cd079d4e
commit d6be1cbf65
3 changed files with 25 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
- Bitstruct truncated constant error escapes `$defined` #2515. - Bitstruct truncated constant error escapes `$defined` #2515.
- Compiler segfault when accessing member of number cast to bitstruct #2516. - Compiler segfault when accessing member of number cast to bitstruct #2516.
- Compiler assert when getting a member of a `bitstruct : char @bigendian` #2517. - Compiler assert when getting a member of a `bitstruct : char @bigendian` #2517.
- Incorrect visibility on local globals with public aliases. #2519
### Stdlib changes ### Stdlib changes

View File

@@ -5302,6 +5302,10 @@ static inline bool sema_analyse_alias(SemaContext *context, Decl *decl, bool *er
} }
decl->type = symbol->type; decl->type = symbol->type;
decl->define_decl.alias = symbol; decl->define_decl.alias = symbol;
if (decl_is_externally_visible(decl) && !decl_is_externally_visible(symbol))
{
symbol->is_external_visible = true;
}
return true; return true;
} }

View File

@@ -0,0 +1,20 @@
// #target: macos-x64
module test1;
alias x = y;
int y @local = 1;
module test;
import test1;
fn int main(String[] args)
{
return test1::x;
}
/* #expect: test1.ll
@test1.y.10 = local_unnamed_addr global i32 1, align 4
// #expect: test.ll
@test1.y.10 = external global i32, align 4