schema compile REFACTOR identity compilation
Identities should always be precompiled but
compiled only if the module is implemented.
The code now reflects this exactly.
diff --git a/src/tree_schema.c b/src/tree_schema.c
index aaeca87..9089a3c 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -1390,17 +1390,15 @@
/* compile features */
LY_CHECK_GOTO(ret = lys_compile_feature_iffeatures(mod->parsed), cleanup);
- if (!implement) {
- /* pre-compile identities of the module */
- LY_CHECK_GOTO(ret = lys_identity_precompile(NULL, ctx, mod->parsed, mod->parsed->identities, &mod->identities), cleanup);
+ /* pre-compile identities of the module and any submodules */
+ LY_CHECK_GOTO(ret = lys_identity_precompile(NULL, ctx, mod->parsed, mod->parsed->identities, &mod->identities), cleanup);
+ LY_ARRAY_FOR(mod->parsed->includes, u) {
+ submod = mod->parsed->includes[u].submodule;
+ ret = lys_identity_precompile(NULL, ctx, (struct lysp_module *)submod, submod->identities, &mod->identities);
+ LY_CHECK_GOTO(ret, cleanup);
+ }
- /* pre-compile identities of any submodules */
- LY_ARRAY_FOR(mod->parsed->includes, u) {
- submod = mod->parsed->includes[u].submodule;
- ret = lys_identity_precompile(NULL, ctx, (struct lysp_module *)submod, submod->identities, &mod->identities);
- LY_CHECK_GOTO(ret, cleanup);
- }
- } else {
+ if (implement) {
/* implement (compile) */
LY_CHECK_GOTO(ret = lys_set_implemented_r(mod, features, unres), cleanup);
}