Closed syyyr closed 2 years ago
Hi, I found this bug that happens since f4fa90dd. When trying to print all enums of the enum2 enumeration, it also prints the ifFeaturedEnum. If I remove the enum1 leaf, everything works correctly.
enum2
ifFeaturedEnum
enum1
#include <iostream> #include <libyang/libyang.h> #include <span> #include <string> const char* my = R"( module my { yang-version 1.1; namespace "http://example.com/example"; prefix coze; leaf enum1 { type enumeration { enum a; } } feature myFeature; leaf enum2 { type enumeration { enum ifFeaturedEnum { if-feature "myFeature"; } enum two; } } })"; int main(int argc, char* argv[]) { ly_ctx* ctx; ly_ctx_new(nullptr, 0, &ctx); lys_module* mod; lys_parse_mem(ctx, my, LYS_IN_YANG, &mod); auto enum_schema = reinterpret_cast<const lysc_node_leaf*>(lys_find_path(ctx, nullptr, "/my:enum2", false)); auto type_enum = reinterpret_cast<lysc_type_enum*>(enum_schema->type); for (const auto& it : std::span(type_enum->enums, LY_ARRAY_COUNT(type_enum->enums))) { std::cerr << "it.name = " << it.name << "\n"; } ly_ctx_destroy(ctx); return 0; }
My bad, should be fixed now.
Thanks.
Hi, I found this bug that happens since f4fa90dd. When trying to print all enums of the
enum2
enumeration, it also prints theifFeaturedEnum
. If I remove theenum1
leaf, everything works correctly.