enforce leading comptime params
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user