From 611d4bc6a1a99f4364b690dea688e81dd599daae Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Sun, 14 Apr 2019 22:47:53 -0400 Subject: stage1: const_values_equal support tagged union --- src/analyze.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index 730c52c927..2775c05b79 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -5158,11 +5158,10 @@ bool const_values_equal(CodeGen *g, ConstExprValue *a, ConstExprValue *b) { if (bigint_cmp(&union1->tag, &union2->tag) == CmpEQ) { TypeUnionField *field = find_union_field_by_tag(a->type, &union1->tag); assert(field != nullptr); - if (type_has_bits(field->type_entry)) { - zig_panic("TODO const expr analyze union field value for equality"); - } else { + if (!type_has_bits(field->type_entry)) return true; - } + assert(find_union_field_by_tag(a->type, &union2->tag) != nullptr); + return const_values_equal(g, union1->payload, union2->payload); } return false; } -- cgit v1.2.3