aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2026-01-02 10:19:23 +0000
committergingerBill <gingerBill@users.noreply.github.com>2026-01-02 10:19:23 +0000
commitbfe75d5c2cfce94b989431ddb2b186a0d877ffe9 (patch)
tree411d147922ab50d6a72282d8c6651c7217b4df1a /core
parentc49a645d34483ef29eb2f9d583154169146e7317 (diff)
Add boolean support for `raw_union_tag`
Diffstat (limited to 'core')
-rw-r--r--core/fmt/fmt.odin29
1 files changed, 29 insertions, 0 deletions
diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin
index 72fe6fdf0..04211b8a9 100644
--- a/core/fmt/fmt.odin
+++ b/core/fmt/fmt.odin
@@ -2159,6 +2159,35 @@ __handle_raw_union_tag :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime.
}
}
}
+
+ case reflect.Type_Info_Boolean:
+ tag_value := reflect.as_bool(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_bool(tail_name) or_continue
+
+ if tail_value == tag_value {
+ io.write_string(fi.writer, "#raw_union(.", &fi.n)
+ io.write_string(fi.writer, "true" if tag_value else "false", &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