From ec5880e7579ccefa7c81b1caf8be9baf15dac72d Mon Sep 17 00:00:00 2001 From: hl-valdemar Date: Wed, 22 Jul 2026 11:32:28 +0200 Subject: [PATCH] caller-context comptime preservation --- compiler/checker/comptime.odin | 15 ++++++++++++--- std/static_string_map/static_string_map.bro | 8 +------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/compiler/checker/comptime.odin b/compiler/checker/comptime.odin index 791ca97..10a3c8d 100644 --- a/compiler/checker/comptime.odin +++ b/compiler/checker/comptime.odin @@ -3491,10 +3491,19 @@ ct_eval_template_call :: proc( if param.comptime_value { continue } - param_type := type_from_syntax(checker, param.type, function.pkg, function.file) if index >= len(args) { return INVALID_CT_VALUE, ct_flow(.Normal), false } + append(&runtime_types, type_from_syntax(checker, param.type, function.pkg, function.file)) + append(&runtime_names, param.name) + } + checker.current_comptime_values = previous_comptime + runtime_index := 0 + for param, index in function.params { + if param.comptime_value { + continue + } + param_type := runtime_types[runtime_index] value, flow, ok := ct_eval_expr(state, args[index], param_type, depth+1) if !ok || flow.kind != .Normal { return INVALID_CT_VALUE, flow, ok @@ -3510,9 +3519,9 @@ ct_eval_template_call :: proc( ) } append(&runtime_values, value) - append(&runtime_types, param_type) - append(&runtime_names, param.name) + runtime_index += 1 } + checker.current_comptime_values = comptime_values previous_pkg := state.pkg previous_file := state.file previous_result := state.result diff --git a/std/static_string_map/static_string_map.bro b/std/static_string_map/static_string_map.bro index 9748b4a..4c51be3 100644 --- a/std/static_string_map/static_string_map.bro +++ b/std/static_string_map/static_string_map.bro @@ -27,13 +27,7 @@ init func($V type, $N usize, $entries [N]Pair(V)) StaticStringMap(V) { compile_error!("static string map key is too long") } for (usize(0))..i |prior| { - other :: entries[prior].0 - equal bool = entry.0.len == other.len - byte_index usize = 0 - while equal and byte_index < entry.0.len : byte_index += 1 { - equal = entry.0[byte_index] == other[byte_index] - } - if equal { + if mem.eql(u8, entry.0, entries[prior].0) { compile_error!("duplicate static string map key") } }