authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-11-04 23:31:38+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-05 12:05:01-05:00
log71e209521a0675a3ec06aba133ce8837e2ee9806
treeb08b47e6608c816ae5848c2075e9d1f886e608ee
parent4e9ab0306ac84227bff1188bbf4d65a1ae5255d9

Mark type fields as CT

Fixes #3276

2 files changed, 9 insertions(+), 0 deletions(-)

src/ir.cpp+2
...@@ -20405,6 +20405,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr...@@ -20405,6 +20405,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
20405 bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 1);20405 bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 1);
2040620406
20407 ConstExprValue *payload = create_const_vals(1);20407 ConstExprValue *payload = create_const_vals(1);
20408 payload->special = ConstValSpecialStatic;
20408 payload->type = ira->codegen->builtin_types.entry_type;20409 payload->type = ira->codegen->builtin_types.entry_type;
20409 payload->data.x_type = var->const_value->type;20410 payload->data.x_type = var->const_value->type;
2041020411
...@@ -20525,6 +20526,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr...@@ -20525,6 +20526,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr
20525 bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 0);20526 bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 0);
2052620527
20527 ConstExprValue *payload = create_const_vals(1);20528 ConstExprValue *payload = create_const_vals(1);
20529 payload->special = ConstValSpecialStatic;
20528 payload->type = ira->codegen->builtin_types.entry_type;20530 payload->type = ira->codegen->builtin_types.entry_type;
20529 payload->data.x_type = type_entry;20531 payload->data.x_type = type_entry;
2053020532
test/stage1/behavior/type_info.zig+7
...@@ -339,3 +339,10 @@ test "type info: extern fns with and without lib names" {...@@ -339,3 +339,10 @@ test "type info: extern fns with and without lib names" {
339 }339 }
340 }340 }
341}341}
342
343test "data field is a compile-time value" {
344 const S = struct {
345 const Bar = isize(-1);
346 };
347 comptime expect(@typeInfo(S).Struct.decls[0].data.Var == isize);
348}