enforce leading comptime params

This commit is contained in:
2026-07-12 19:48:36 +02:00
parent 2dea7711f2
commit c914083102
4 changed files with 52 additions and 0 deletions
+14
View File
@@ -2060,7 +2060,21 @@ validate_declarations :: proc(checker: ^Checker) {
has_comptime := function_has_comptime_params(function)
locals: [dynamic]symbol.Id
locals.allocator = checker.allocator
seen_runtime_param := false
comptime_order_reported := false
for param in function.params {
if param.comptime_value {
if seen_runtime_param && !comptime_order_reported {
checker.template_diagnostics[function_id] = source.add(
checker.diagnostics,
param.span,
"comptime parameters must form a leading parameter prefix",
)
comptime_order_reported = true
}
} else {
seen_runtime_param = true
}
param_type := types.INVALID
if param.comptime_value || !has_comptime {
param_type = type_from_syntax(checker, param.type, function.pkg, function.file)