authorgravatar for sahnvour@pm.meSahnvour <sahnvour@pm.me> 2019-03-05 22:12:53+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-03-06 15:27:56-05:00
log5469e3e3c1ae060ee04f554499c852603eef3a5f
tree9db7222ce20ae0ffb0f2a38344e8b72aae501d9a
parente2f4df60651e81d0f9d60f990acdadd28cc5b41f

missed change when switching TypeInfo to use comptime_int

fixes #2030

2 files changed, 11 insertions(+), 1 deletions(-)

src/ir.cpp+1-1
...@@ -18466,7 +18466,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr...@@ -18466,7 +18466,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
18466 size_t byte_offset = LLVMOffsetOfElement(ira->codegen->target_data_ref, type_entry->type_ref, struct_field->gen_index);18466 size_t byte_offset = LLVMOffsetOfElement(ira->codegen->target_data_ref, type_entry->type_ref, struct_field->gen_index);
18467 inner_fields[1].data.x_optional = create_const_vals(1);18467 inner_fields[1].data.x_optional = create_const_vals(1);
18468 inner_fields[1].data.x_optional->special = ConstValSpecialStatic;18468 inner_fields[1].data.x_optional->special = ConstValSpecialStatic;
18469 inner_fields[1].data.x_optional->type = ira->codegen->builtin_types.entry_usize;18469 inner_fields[1].data.x_optional->type = ira->codegen->builtin_types.entry_num_lit_int;
18470 bigint_init_unsigned(&inner_fields[1].data.x_optional->data.x_bigint, byte_offset);18470 bigint_init_unsigned(&inner_fields[1].data.x_optional->data.x_bigint, byte_offset);
18471 }18471 }
1847218472
test/stage1/behavior/type_info.zig+10
...@@ -289,3 +289,13 @@ fn testVector() void {...@@ -289,3 +289,13 @@ fn testVector() void {
289 expect(vec_info.Vector.len == 4);289 expect(vec_info.Vector.len == 4);
290 expect(vec_info.Vector.child == i32);290 expect(vec_info.Vector.child == i32);
291}291}
292
293test "type info: optional field unwrapping" {
294 const Struct = struct {
295 cdOffset: u32,
296 };
297
298 const field = @typeInfo(Struct).Struct.fields[0];
299
300 _ = field.offset orelse 0;
301}