- Compiler segfault for invalid e-mails in project.json. #2488

- `env::PROJECT_VERSION` now returns the version in project.json.
This commit is contained in:
Christoffer Lerno
2025-09-18 10:58:15 +02:00
parent 35270fb0bf
commit c5e3a1b2da
5 changed files with 6 additions and 2 deletions

View File

@@ -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);

View File

@@ -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

View File

@@ -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:");

View File

@@ -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);

View File

@@ -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();