parser CHANGE allow require-instance property change in derived types
... but print a warning. Based on the conclusion of
the discussion in the mailing list.
Fixes #1049
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 6982268..130ba3f 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -1205,7 +1205,6 @@
case LY_TYPE_INST:
/* RFC 6020 9.13.2 - require-instance */
LY_TREE_FOR(yin->child, node) {
-
if (!strcmp(node->name, "require-instance")) {
if (type->info.inst.req) {
LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
@@ -1231,6 +1230,11 @@
}
}
+ if (type->der->type.der && !type->info.inst.req) {
+ /* inherit require-instance property */
+ type->info.inst.req = type->der->type.info.inst.req;
+ }
+
break;
case LY_TYPE_BINARY:
@@ -1304,7 +1308,7 @@
LY_TREE_FOR(yin->child, node) {
if (!strcmp(node->name, "path") && !type->der->type.der) {
/* keep path for later */
- } else if (module->version >= 2 && !strcmp(node->name, "require-instance") && !type->der->type.der) {
+ } else if (module->version >= 2 && !strcmp(node->name, "require-instance")) {
if (type->info.lref.req) {
LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
goto error;
@@ -1371,7 +1375,9 @@
} else {
/* copy leafref definition into the derived type */
type->info.lref.path = lydict_insert(ctx, type->der->type.info.lref.path, 0);
- type->info.lref.req = type->der->type.info.lref.req;
+ if (!type->info.lref.req) {
+ type->info.lref.req = type->der->type.info.lref.req;
+ }
/* and resolve the path at the place we are (if not in grouping/typedef) */
if (!parenttype && unres_schema_add_node(module, unres, type, UNRES_TYPE_LEAFREF, parent) == -1) {
goto error;