- Assert when encountering a test function with raw vaarg parameters.

This commit is contained in:
Christoffer Lerno
2025-12-30 12:28:03 +01:00
parent e4f1b57bd0
commit 90f0486334
4 changed files with 5 additions and 2 deletions

View File

@@ -40,6 +40,7 @@
- Parse error in `$defined` was not handled correctly, leading to an assertion.
- Assert when struct size would exceed 4 GB.
- Assert when encountering a malformed module alias.
- Assert when encountering a test function with raw vaarg parameters.
### Stdlib changes
- Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads.

View File

@@ -4269,7 +4269,8 @@ static inline bool sema_analyse_func(SemaContext *context, Decl *decl, bool *era
unsigned params = vec_size(sig->params);
if (params)
{
RETURN_SEMA_ERROR(sig->params[0], "%s functions may not take any parameters.",
SourceSpan span = sig->params[0] ? sig->params[0]->span : decl->span;
RETURN_SEMA_ERROR_AT(span, "%s functions may not take any parameters.",
is_init_finalizer ? "'@init' and '@finalizer'" : "'@test' and '@benchmark'");
}
TypeInfo *rtype_info = type_infoptr(sig->rtype);

View File

@@ -299,7 +299,7 @@ fn bool parse_result(DString out, RunSettings settings, List{String}* cmdline, O
if (!find_and_mark_error(&settings, ...parts[:5]))
{
unexpected_errors.push(string::tformat(" - %s at %s:%s: \"%s\"", parts[0], parts[1].file_tbasename()!!, parts[2], parts[4]));
unexpected_errors.push(string::tformat(" - %s at %s:%s: %s", parts[0], parts[1].file_tbasename()!!, parts[2], parts[4]));
}
}

View File

@@ -0,0 +1 @@
fn void asdf(...) @test; // #error: '@test' and '@benchmark' functions may not take any parameters.