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/schema_compile.c b/src/schema_compile.c
index 2973434..e622510 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -1459,17 +1459,9 @@
struct lysp_submodule *submod;
LY_ARRAY_COUNT_TYPE u;
- if (!ctx->cur_mod->identities) {
- LY_CHECK_RET(lys_identity_precompile(ctx, NULL, NULL, ctx->cur_mod->parsed->identities, &ctx->cur_mod->identities));
- LY_ARRAY_FOR(ctx->cur_mod->parsed->includes, u) {
- submod = ctx->cur_mod->parsed->includes[u].submodule;
- LY_CHECK_RET(lys_identity_precompile(ctx, NULL, NULL, submod->identities, &ctx->cur_mod->identities));
- }
- }
if (ctx->cur_mod->parsed->identities) {
LY_CHECK_RET(lys_compile_identities_derived(ctx, ctx->cur_mod->parsed->identities, &ctx->cur_mod->identities));
}
-
lysc_update_path(ctx, NULL, "{submodule}");
LY_ARRAY_FOR(ctx->cur_mod->parsed->includes, u) {
submod = ctx->cur_mod->parsed->includes[u].submodule;
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);
}