diff options
| author | LemonBoy <LemonBoy@users.noreply.github.com> | 2019-02-19 21:18:57 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-02-19 15:18:57 -0500 |
| commit | 400006bbe790f2173fd6e40d80608691a95b437e (patch) | |
| tree | 42d980d1b064c0efd1f8aa602e03994f811129e3 /src | |
| parent | db74832e40f98960e5dc3e46c8196c59033ee0f9 (diff) | |
| download | zig-400006bbe790f2173fd6e40d80608691a95b437e.tar.gz zig-400006bbe790f2173fd6e40d80608691a95b437e.zip | |
Prevent crash in tagged enums rendering (#1986)
* Prevent crash in tagged enums rendering
* Add a test case
Diffstat (limited to 'src')
| -rw-r--r-- | src/analyze.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index b6d54c0da8..9fe656ff77 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -6276,8 +6276,8 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) { } case ZigTypeIdUnion: { - uint64_t tag = bigint_as_unsigned(&const_val->data.x_union.tag); - TypeUnionField *field = &type_entry->data.unionation.fields[tag]; + const BigInt *tag = &const_val->data.x_union.tag; + TypeUnionField *field = find_union_field_by_tag(type_entry, tag); buf_appendf(buf, "%s { .%s = ", buf_ptr(&type_entry->name), buf_ptr(field->name)); render_const_value(g, buf, const_val->data.x_union.payload); buf_append_str(buf, "}"); |
