diff --git a/lib/std/libc/os/posix.c3 b/lib/std/libc/os/posix.c3 index 94dd7086a..aaf32bd82 100644 --- a/lib/std/libc/os/posix.c3 +++ b/lib/std/libc/os/posix.c3 @@ -4,10 +4,10 @@ def Pid_t = int; def Uid_t = uint; def Gid_t = uint; -const CInt SA_ONSTACK = env::LINUX ? 0x08000000 : 0x0001; -const CInt SA_RESTART = env::LINUX ? 0x10000000 : 0x0002; -const CInt SA_RESETHAND = env::LINUX ? 0x80000000 : 0x0004; -const CInt SA_SIGINFO = env::LINUX ? 0x00000004 : 0x0040; +const CUInt SA_ONSTACK = env::LINUX ? 0x08000000 : 0x0001; +const CUInt SA_RESTART = env::LINUX ? 0x10000000 : 0x0002; +const CUInt SA_RESETHAND = env::LINUX ? 0x80000000 : 0x0004; +const CUInt SA_SIGINFO = env::LINUX ? 0x00000004 : 0x0040; def Sigset_t = uint @if(!env::LINUX); def Sigset_t = ulong[16] @if(env::LINUX); @@ -20,18 +20,25 @@ struct Sigaction SignalFunction sa_handler; SigActionFunction sa_sigaction; } - CInt sa_flags @if(env::FREEBSD); - Sigset_t sa_mask; // 128 - CInt sa_flags @if(!env::FREEBSD); - void* sa_restorer @if(env::LINUX); + CInt sa_flags @if(env::FREEBSD); + Sigset_t sa_mask; // 128 + CInt sa_flags @if(!env::FREEBSD); + void* sa_restorer @if(env::LINUX); } struct Stack_t { void* ss_sp; - usz ss_size @if(!env::LINUX); - CInt ss_flags; - usz ss_size @if(env::LINUX); + struct @if(!env::LINUX) + { + usz ss_size; + CInt ss_flags; + } + struct @if(env::LINUX) + { + CInt ss_flags; + usz ss_size; + } } extern fn CInt sigaltstack(Stack_t* ss, Stack_t* old_ss); diff --git a/src/build/project_creation.c b/src/build/project_creation.c index cdcb3c0be..49da2ac00 100644 --- a/src/build/project_creation.c +++ b/src/build/project_creation.c @@ -209,7 +209,30 @@ void create_project(BuildOptions *build_options) file = fopen("main.c3", "w"); if (!file) goto ERROR; - (void) fprintf(file, MAIN_TEMPLATE, build_options->project_name); + + scratch_buffer_clear(); + size_t len = strlen(build_options->project_name); + bool has_char = false; + for (size_t i = 0; i < len; i++) + { + char c = build_options->project_name[i]; + if (c >= '0' && c <= '9') + { + if (!has_char) scratch_buffer_append("m_"); + has_char = true; + scratch_buffer_append_char(c); + continue; + } + if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) + { + scratch_buffer_append_char(c | 0x20); + has_char = true; + continue; + } + scratch_buffer_append_char('_'); + } + if (!has_char) scratch_buffer_append("module"); + (void) fprintf(file, MAIN_TEMPLATE, scratch_buffer_to_string()); if (fclose(file)) goto ERROR; if (!dir_change("..")) goto ERROR; diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index 410f56d31..3584f8ca5 100644 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -3191,6 +3191,10 @@ static bool sema_append_generate_parameterized_name(SemaContext *c, Module *modu if (type->type_kind == TYPE_OPTIONAL) RETURN_SEMA_ERROR(type_info, "Expected a non-optional type."); if (type == type_void) RETURN_SEMA_ERROR(type_info, "A 'void' type cannot be used as a parameter type."); if (type_is_invalid_storage_type(type)) RETURN_SEMA_ERROR(type_info, "Expected a runtime type."); + if (type_is_func_ptr(type)) + { + if (!sema_resolve_type_decl(c, type->pointer)) return false; + } if (mangled) { type_mangle_introspect_name_to_buffer(type); diff --git a/src/version.h b/src/version.h index 259130589..e1900585d 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.655" \ No newline at end of file +#define COMPILER_VERSION "0.4.656" \ No newline at end of file diff --git a/test/test_suite/functions/recursive_through_generic.c3 b/test/test_suite/functions/recursive_through_generic.c3 new file mode 100644 index 000000000..1b250e547 --- /dev/null +++ b/test/test_suite/functions/recursive_through_generic.c3 @@ -0,0 +1,14 @@ +module oups; +import std::collections::map; + +fn void! main() +{ +} + +def FooFunc = fn void! (Bar*); // #error: Recursive definition +def Foo = HashMap(); + +struct Bar +{ + Foo foo; +} \ No newline at end of file