zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 5469e3e3c1ae060ee04f554499c852603eef3a5f (tree)
parent e2f4df60651e81d0f9d60f990acdadd28cc5b41f
Author: Sahnvour <sahnvour@pm.me>
Date:   Tue,  5 Mar 2019 22:12:53 +0100

missed change when switching TypeInfo to use comptime_int

fixes #2030

Diffstat:
Msrc/ir.cpp | 2+-
Mtest/stage1/behavior/type_info.zig | 10++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/ir.cpp b/src/ir.cpp @@ -18466,7 +18466,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr size_t byte_offset = LLVMOffsetOfElement(ira->codegen->target_data_ref, type_entry->type_ref, struct_field->gen_index); inner_fields[1].data.x_optional = create_const_vals(1); inner_fields[1].data.x_optional->special = ConstValSpecialStatic; - inner_fields[1].data.x_optional->type = ira->codegen->builtin_types.entry_usize; + inner_fields[1].data.x_optional->type = ira->codegen->builtin_types.entry_num_lit_int; bigint_init_unsigned(&inner_fields[1].data.x_optional->data.x_bigint, byte_offset); } diff --git a/test/stage1/behavior/type_info.zig b/test/stage1/behavior/type_info.zig @@ -289,3 +289,13 @@ fn testVector() void { expect(vec_info.Vector.len == 4); expect(vec_info.Vector.child == i32); } + +test "type info: optional field unwrapping" { + const Struct = struct { + cdOffset: u32, + }; + + const field = @typeInfo(Struct).Struct.fields[0]; + + _ = field.offset orelse 0; +}