From 3883d079c8cf78ad49c6b140cf37b943c27c27c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A4rtschi=20Robin?= Date: Wed, 24 Jun 2026 08:04:17 +0200 Subject: [PATCH] Fix #6874 --- core/encoding/json/types.odin | 1 + src/check_stmt.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/core/encoding/json/types.odin b/core/encoding/json/types.odin index 77cc7db85..6b6d8aae9 100644 --- a/core/encoding/json/types.odin +++ b/core/encoding/json/types.odin @@ -113,6 +113,7 @@ destroy_value :: proc(value: Value, allocator := context.allocator, loc := #call } clone_value :: proc(value: Value, allocator := context.allocator) -> Value { + value := value context.allocator = allocator #partial switch &v in value { diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 53dae5fd5..222222559 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1476,6 +1476,14 @@ gb_internal void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_ return; } + if (switch_kind == TypeSwitch_Union) { + if (is_addressed) { + if (x.mode != Addressing_Variable && !is_type_pointer(x.type)) { + error(lhs->Ident.token, "The element variable '%.*s' cannot be made addressable", LIT(lhs->Ident.token.string)); + } + } + } + Ast *nil_seen = nullptr; TypeSet seen = {};