weak contextual string-literal inference

This commit is contained in:
2026-07-22 02:30:39 +02:00
parent c389c19a81
commit 63f000dd42
2 changed files with 54 additions and 4 deletions
+5 -4
View File
@@ -2804,9 +2804,9 @@ infer_call_comptime_values :: proc(
for value_bound in bound {
all_bound = all_bound && value_bound
}
// Concrete arguments bind first. Numeric constants and `null` are contextual and
// therefore only contribute after stronger evidence has had a chance to bind the
// parameter type.
// Concrete arguments bind first. Numeric constants, string literals, and `null`
// are contextual and therefore only contribute after stronger evidence has had a
// chance to bind the parameter type.
weak_passes := [2]bool{false, true}
for weak in weak_passes {
for arg_id, source_index in args {
@@ -2819,7 +2819,8 @@ infer_call_comptime_values :: proc(
}
arg_expr := checker.ast_module.exprs[arg_id]
is_null := arg_expr.kind == .Null
is_weak := is_numeric_constant_expr(checker, arg_id) || is_null
is_weak := is_numeric_constant_expr(checker, arg_id) ||
arg_expr.kind == .String || is_null
if is_weak != weak {
continue
}