schema compile BUGFIX handle recursive augments/refines
diff --git a/src/schema_compile_amend.c b/src/schema_compile_amend.c
index 63d516b..1dfed53 100644
--- a/src/schema_compile_amend.c
+++ b/src/schema_compile_amend.c
@@ -230,6 +230,7 @@
exp = NULL;
rfn->nodeid_pmod = ctx->pmod;
rfn->nodeid_ctx_node = ctx_node;
+ rfn->uses_p = uses_p;
} else {
/* just free exp */
lyxp_expr_free(ctx->ctx, exp);
diff --git a/src/schema_compile_amend.h b/src/schema_compile_amend.h
index 0ab98a8..e9ec1ed 100644
--- a/src/schema_compile_amend.h
+++ b/src/schema_compile_amend.h
@@ -57,6 +57,7 @@
struct lyxp_expr *nodeid; /**< refine target */
const struct lysp_module *nodeid_pmod; /**< module where the nodeid is defined, used to resolve prefixes */
const struct lysc_node *nodeid_ctx_node; /**< nodeid context node */
+ struct lysp_node_uses *uses_p; /**< parsed uses node of the refine, for tracking recursive refines */
struct lysp_refine **rfns; /**< sized array of parsed refines to apply */
};
diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c
index 93b15ab..ba5b96c 100644
--- a/src/schema_compile_node.c
+++ b/src/schema_compile_node.c
@@ -3475,8 +3475,12 @@
/* check that all augments were applied */
for (i = 0; i < ctx->uses_augs.count; ++i) {
- LOGVAL(ctx->ctx, LYVE_REFERENCE,
- "Augment target node \"%s\" in grouping \"%s\" was not found.",
+ if (((struct lysc_augment *)ctx->uses_augs.objs[i])->aug_p->parent != (struct lysp_node *)uses_p) {
+ /* augment of some parent uses, irrelevant now */
+ continue;
+ }
+
+ LOGVAL(ctx->ctx, LYVE_REFERENCE, "Augment target node \"%s\" in grouping \"%s\" was not found.",
((struct lysc_augment *)ctx->uses_augs.objs[i])->nodeid->expr, grp->name);
ret = LY_ENOTFOUND;
}
@@ -3484,8 +3488,12 @@
/* check that all refines were applied */
for (i = 0; i < ctx->uses_rfns.count; ++i) {
- LOGVAL(ctx->ctx, LYVE_REFERENCE,
- "Refine(s) target node \"%s\" in grouping \"%s\" was not found.",
+ if (((struct lysc_refine *)ctx->uses_rfns.objs[i])->uses_p != uses_p) {
+ /* refine of some paretn uses, irrelevant now */
+ continue;
+ }
+
+ LOGVAL(ctx->ctx, LYVE_REFERENCE, "Refine(s) target node \"%s\" in grouping \"%s\" was not found.",
((struct lysc_refine *)ctx->uses_rfns.objs[i])->nodeid->expr, grp->name);
ret = LY_ENOTFOUND;
}