Lambdas on the top level were not exported by default. #2428

This commit is contained in:
Christoffer Lerno
2025-08-23 19:40:18 +02:00
parent 768ce6092d
commit a004cd3d03
4 changed files with 21 additions and 4 deletions

View File

@@ -61,6 +61,7 @@
- `Socket.get_option` didn't properly call `getsockopt`, and `getsockopt` had an invalid signature. - `Socket.get_option` didn't properly call `getsockopt`, and `getsockopt` had an invalid signature.
- Taking the address of a label would cause a crash. #2430 - Taking the address of a label would cause a crash. #2430
- `@tag` was not allowed to repeat. - `@tag` was not allowed to repeat.
- Lambdas on the top level were not exported by default. #2428
### Stdlib changes ### Stdlib changes
- Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`. - Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`.

View File

@@ -44,10 +44,6 @@ void llvm_value_set(BEValue *value, LLVMValueRef llvm_value, Type *type)
void llvm_value_set_address(GenContext *c, BEValue *value, LLVMValueRef llvm_value, Type *type, AlignSize alignment) void llvm_value_set_address(GenContext *c, BEValue *value, LLVMValueRef llvm_value, Type *type, AlignSize alignment)
{ {
if (alignment == 0)
{
puts("TODO");
}
ASSERT(alignment > 0); ASSERT(alignment > 0);
if (LLVMIsAGlobalVariable(llvm_value) && LLVMIsThreadLocal(llvm_value)) if (LLVMIsAGlobalVariable(llvm_value) && LLVMIsThreadLocal(llvm_value))
{ {

View File

@@ -10218,6 +10218,7 @@ static inline bool sema_expr_analyse_lambda(SemaContext *context, Type *target_t
{ {
decl->var.is_read = true; decl->var.is_read = true;
} }
decl->is_external_visible = true;
vec_add(unit->module->lambdas_to_evaluate, decl); vec_add(unit->module->lambdas_to_evaluate, decl);
} }
else else

View File

@@ -0,0 +1,19 @@
// #target: macos-x64
module test;
alias SomethingFn = fn void();
enum TestEnum : char (SomethingFn f)
{
FOO = fn () {}
}
/* #expect: test.ll
@.enum.FOO = internal constant [4 x i8] c"FOO\00", align 1
@"$ct.char" = linkonce global %.introspect { i8 3, i64 0, ptr null, i64 1, i64 0, i64 0, [0 x i64] zeroinitializer }, align 8
@"$ct.test.TestEnum" = linkonce global { i8, i64, ptr, i64, i64, i64, [1 x %"char[]"] } { i8 8, i64 0, ptr null, i64 1, i64 ptrtoint (ptr @"$ct.char" to i64), i64 1, [1 x %"char[]"] [%"char[]" { ptr @.enum.FOO, i64 3 }] }, align 8
@"test.TestEnum$f" = linkonce constant [1 x ptr] [ptr @"test.$global$lambda1"], align 8
define void @"test.$global$lambda1"() #0 {
entry:
ret void
}