From 9fad24d8918194f5ab71153db6fb06d2a3738dfb Mon Sep 17 00:00:00 2001 From: yuyi Date: Wed, 9 Oct 2024 23:05:11 +0800 Subject: [PATCH] change in reflection.v --- vlib/v/gen/c/reflection.v | 2 +- vlib/v/reflection/reflection.v | 4 ++-- vlib/v/tests/reflection_sym_test.v | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vlib/v/gen/c/reflection.v b/vlib/v/gen/c/reflection.v index 7f3e20435b71df..120b194086f28e 100644 --- a/vlib/v/gen/c/reflection.v +++ b/vlib/v/gen/c/reflection.v @@ -80,7 +80,7 @@ fn (mut g Gen) gen_reflection_fn(node ast.Fn) string { // gen_reflection_sym generates C code for TypeSymbol struct @[inline] fn (mut g Gen) gen_reflection_sym(tsym ast.TypeSymbol) string { - kind_name := if tsym.kind in [.none_, .struct, .enum_, .interface_] { + kind_name := if tsym.kind in [.none_, .enum_, .interface_] { tsym.kind.str() + '_' } else { tsym.kind.str() diff --git a/vlib/v/reflection/reflection.v b/vlib/v/reflection/reflection.v index 4bdbdc863a88c7..d7fe68af2e7b79 100644 --- a/vlib/v/reflection/reflection.v +++ b/vlib/v/reflection/reflection.v @@ -71,7 +71,7 @@ pub enum VKind { map chan any - struct_ + struct generic_inst multi_return sum_type @@ -258,7 +258,7 @@ pub fn get_funcs() []Function { } pub fn get_structs() []Type { - struct_idxs := g_reflection.type_symbols.filter(it.kind == .struct_).map(it.idx) + struct_idxs := g_reflection.type_symbols.filter(it.kind == .struct).map(it.idx) return g_reflection.types.filter(it.idx in struct_idxs) } diff --git a/vlib/v/tests/reflection_sym_test.v b/vlib/v/tests/reflection_sym_test.v index 0e571a1488a984..b79f13c4fa17a9 100644 --- a/vlib/v/tests/reflection_sym_test.v +++ b/vlib/v/tests/reflection_sym_test.v @@ -94,7 +94,7 @@ fn test_enum_sym() { fn test_struct_sym() { var := reflection.type_of(Test{}) - assert var.sym.kind == .struct_ + assert var.sym.kind == .struct assert (var.sym.info as reflection.Struct).attrs.len == 1 assert (var.sym.info as reflection.Struct).attrs == ['test_struct']