From 3a3239294c9e4a7504bfb60e3cb5f8229fe6a326 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 8 Dec 2025 14:03:13 +0000 Subject: [PATCH] `raw_union_tag` allow for comma separation for multiple mappings --- core/fmt/fmt.odin | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index fd0af7559..c05b8eb62 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -2112,21 +2112,26 @@ __handle_raw_union_tag :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime. tag_string := reflect.enum_string(tag) for tag, index in info.tags[:info.field_count] { - rut := reflect.struct_tag_lookup(reflect.Struct_Tag(tag), "raw_union_tag") or_continue - head_tag, match, tail_name := strings.partition(string(rut), "=") - if head_tag != tag_name || match != "=" { - continue - } + rut_list := reflect.struct_tag_lookup(reflect.Struct_Tag(tag), "raw_union_tag") or_continue - // just ignore the `A.` prefix for `A.B` stuff entirely - if _, _, try_tail_name := strings.partition(string(rut), "."); try_tail_name != "" { - tail_name = try_tail_name - } + for rut in strings.split_iterator(&rut_list, ",") { + head_tag, match, tail_name := strings.partition(string(rut), "=") + if head_tag != tag_name || match != "=" { + continue + } - if tail_name == tag_string { - io.write_string(fi.writer, "#raw_union ", &fi.n) - fmt_arg(fi, any{v.data, info.types[index].id}, the_verb) - return true + // just ignore the `A.` prefix for `A.B` stuff entirely + if _, _, try_tail_name := strings.partition(string(rut), "."); try_tail_name != "" { + tail_name = try_tail_name + } + + if tail_name == tag_string { + io.write_string(fi.writer, "#raw_union(.", &fi.n) + io.write_string(fi.writer, tag_string, &fi.n) + io.write_string(fi.writer, ") ", &fi.n) + fmt_arg(fi, any{v.data, info.types[index].id}, the_verb) + return true + } } } }