diff --git a/lib/std/core/env.c3 b/lib/std/core/env.c3 index f7d08cd68..acdfc17da 100644 --- a/lib/std/core/env.c3 +++ b/lib/std/core/env.c3 @@ -206,5 +206,6 @@ macro bool os_is_posix() @const } const String[] AUTHORS = $$AUTHORS; const String[] AUTHOR_EMAILS = $$AUTHOR_EMAILS; +const String PROJECT_VERSION = $$PROJECT_VERSION; const BUILTIN_EXPECT_IS_DISABLED = $feature(DISABLE_BUILTIN_EXPECT); const BUILTIN_PREFETCH_IS_DISABLED = $feature(DISABLE_BUILTIN_PREFETCH); diff --git a/releasenotes.md b/releasenotes.md index 0f041a9b2..1bbc99493 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -8,6 +8,7 @@ - `$alignof`, `$offsetof` and `$nameof` can now be used in `$defined`. - Infer generic parameters lhs -> rhs: `List{int} x = list::NOHEAP`. - Unify generic and regular module namespace. +- `env::PROJECT_VERSION` now returns the version in project.json. ### Fixes - Compiler assert with var x @noinit = 0 #2452 @@ -28,6 +29,7 @@ - Compile time switch over type would not correctly compare function pointer types. - Regression: Compiler segfault when assigning struct literal with too few members #2483 - Fix compile time format check when the formatting string is a constant slice. +- Compiler segfault for invalid e-mails in project.json. #2488 ### Stdlib changes - Added generic `InterfaceList` to store a list of values that implement a specific interface diff --git a/resources/testproject/src/hello_world.c3 b/resources/testproject/src/hello_world.c3 index ea9a2239f..8e74f2ff7 100644 --- a/resources/testproject/src/hello_world.c3 +++ b/resources/testproject/src/hello_world.c3 @@ -7,7 +7,7 @@ extern fn void printf(char *, ...); fn int main() { - printf("Hello World!\n"); + printf("Hello World %s!\n", env::PROJECT_VERSION); printf("Authors:"); io::printn(env::AUTHORS); printf("Author emails:"); diff --git a/src/build/project.c b/src/build/project.c index 2e7899c72..e0df5e42d 100644 --- a/src/build/project.c +++ b/src/build/project.c @@ -194,7 +194,7 @@ static void load_into_build_target(BuildParseContext context, JSONObject *json, if (email_start) { const char *end = strstr(email_start + 1, ">"); - if (!end || end[1] != 0 || email_start + 1 == end) error_exit("Error reading %s: invalid author format '%s'", author); + if (!end || end[1] != 0 || email_start + 1 == end) error_exit("Error reading %s: invalid author format '%s', expected an e-mail address between '< >'.", context.file, author); const char *email = str_trim(str_copy(email_start + 1, end - email_start - 1)); AuthorEntry entry = { str_trim(str_copy(author, email_start - author)), email }; vec_add(author_list, entry); diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c index ea252d316..4250a63e8 100644 --- a/src/compiler/compiler.c +++ b/src/compiler/compiler.c @@ -1518,6 +1518,7 @@ void compile() } setup_define("AUTHORS", expr_names); setup_define("AUTHOR_EMAILS", expr_emails); + setup_string_define("PROJECT_VERSION", compiler.build.version); type_init_cint(); compiler_init_time = bench_mark();