From 71e209521a0675a3ec06aba133ce8837e2ee9806 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 4 Nov 2019 23:31:38 +0100 Subject: [PATCH] Mark type fields as CT Fixes #3276 --- src/ir.cpp | 2 ++ test/stage1/behavior/type_info.zig | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/ir.cpp b/src/ir.cpp index 35ef2b98e23627120a8a5326176d93af1152b25a..d5633b0538f629f7e80462dfedcabc4d657e055d 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -20405,6 +20405,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 1); ConstExprValue *payload = create_const_vals(1); + payload->special = ConstValSpecialStatic; payload->type = ira->codegen->builtin_types.entry_type; payload->data.x_type = var->const_value->type; @@ -20525,6 +20526,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 0); ConstExprValue *payload = create_const_vals(1); + payload->special = ConstValSpecialStatic; payload->type = ira->codegen->builtin_types.entry_type; payload->data.x_type = type_entry; diff --git a/test/stage1/behavior/type_info.zig b/test/stage1/behavior/type_info.zig index b86ba27c13b73c83d6e8e60243239dc5ec182bd8..aafce2990cc8c1b69419377fa629562fea974c76 100644 --- a/test/stage1/behavior/type_info.zig +++ b/test/stage1/behavior/type_info.zig @@ -339,3 +339,10 @@ test "type info: extern fns with and without lib names" { } } } + +test "data field is a compile-time value" { + const S = struct { + const Bar = isize(-1); + }; + comptime expect(@typeInfo(S).Struct.decls[0].data.Var == isize); +} -- 2.54.0