If our parent uses node is not supported by features, we should not be
trying to enforce the augmentation dependency, as it will not be
present.
JIRA: YANGTOOLS-1393
Change-Id: I4b9cff536f4bbd33314f8befb1d70151a5f4f5de
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
* Do not fail, if it is an uses-augment to an unknown node.
*/
if (YangStmtMapping.USES == augmentNode.coerceParentContext().publicDefinition()) {
* Do not fail, if it is an uses-augment to an unknown node.
*/
if (YangStmtMapping.USES == augmentNode.coerceParentContext().publicDefinition()) {
+ if (!augmentNode.isSupportedToBuildEffective()) {
+ // We are not supported, hence the uses is not effective and we should bail
+ return;
+ }
+
final SchemaNodeIdentifier augmentArg = augmentNode.getArgument();
final Optional<StmtContext<?, ?, ?>> targetNode = SchemaTreeNamespace.findNode(
AbstractAugmentStatementSupport.getSearchRoot(augmentNode), augmentArg);
final SchemaNodeIdentifier augmentArg = augmentNode.getArgument();
final Optional<StmtContext<?, ?, ?>> targetNode = SchemaTreeNamespace.findNode(
AbstractAugmentStatementSupport.getSearchRoot(augmentNode), augmentArg);
.orElseThrow();
assertEquals(5, module.effectiveSubstatements().size());
}
.orElseThrow();
assertEquals(5, module.effectiveSubstatements().size());
}
+
+ @Test
+ public void testUsesAugmentInUnsupportedByFeatures() throws Exception {
+ final var module = StmtTestUtils.parseYangSource("/bugs/YT1393/xyzzy.yang", Set.of())
+ .findModuleStatement(QName.create("xyzzy", "xyzzy"))
+ .orElseThrow();
+ assertEquals(3, module.effectiveSubstatements().size());
+ }
--- /dev/null
+module xyzzy {
+ namespace xyzzy;
+ prefix xyzzy;
+
+ feature bar;
+
+ grouping foo {
+ container foo;
+ }
+
+ container bar {
+ if-feature bar;
+
+ uses foo {
+ augment foo {
+ leaf foo {
+ type string;
+ }
+ }
+ }
+ }
+}