Skip to content

Commit

Permalink
missed change when switching TypeInfo to use comptime_int
Browse files Browse the repository at this point in the history
fixes #2030
  • Loading branch information
Sahnvour authored and andrewrk committed Mar 6, 2019
1 parent e2f4df6 commit 5469e3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
10 changes: 10 additions & 0 deletions test/stage1/behavior/type_info.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 5469e3e

Please sign in to comment.