aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2026-01-02 10:13:31 +0000
committergingerBill <gingerBill@users.noreply.github.com>2026-01-02 10:13:31 +0000
commit25daf520001d4fbf14d610fa8e0bfb4fd8bdc3b6 (patch)
tree1c6d500984946f7ab0be14d4ed82d5ef212a3597 /core
parent111ed21e7e5f7ca4cb4358073ab060d138fc782f (diff)
Add support to `raw_union_tag` for integers
Diffstat (limited to 'core')
-rw-r--r--core/fmt/fmt.odin28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin
index a87529174..72fe6fdf0 100644
--- a/core/fmt/fmt.odin
+++ b/core/fmt/fmt.odin
@@ -2131,6 +2131,34 @@ __handle_raw_union_tag :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime.
}
}
}
+ case reflect.Type_Info_Integer:
+ tag_value := reflect.as_i64(tag) or_break
+
+ for tag, index in info.tags[:info.field_count] {
+ rut_list := reflect.struct_tag_lookup(reflect.Struct_Tag(tag), "raw_union_tag") or_continue
+
+ for rut in strings.split_iterator(&rut_list, ",") {
+ head_tag, match, tail_name := strings.partition(string(rut), "=")
+ if head_tag != tag_name || match != "=" {
+ 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
+ }
+
+ tail_value := strconv.parse_i64(tail_name) or_continue
+
+ if tail_value == tag_value {
+ io.write_string(fi.writer, "#raw_union(.", &fi.n)
+ io.write_i64(fi.writer, tag_value, 10, &fi.n)
+ io.write_string(fi.writer, ") ", &fi.n)
+ fmt_arg(fi, any{v.data, info.types[index].id}, the_verb)
+ return true
+ }
+ }
+ }
}
return false