} else if (childNode instanceof Key_stmtContext) {
final Set<String> key = createListKey((Key_stmtContext) childNode);
builder.setKeys(key);
+ } else if (childNode instanceof YangParser.Identifier_stmtContext) {
+ if (childNode.getChild(0).toString().equals("union")) {
+ throw new YangParseException(moduleName, line, "Union statement is not allowed inside a list statement");
+ }
}
}
}
import org.opendaylight.yangtools.yang.model.util.IdentityrefType;
import org.opendaylight.yangtools.yang.model.util.InstanceIdentifierType;
import org.opendaylight.yangtools.yang.model.util.UnionType;
+import org.opendaylight.yangtools.yang.parser.util.YangParseException;
public class TypesResolutionTest {
private Set<Module> testedModules;
parser.parseFiles(Arrays.asList(unionbits));
}
+ @Test(expected = YangParseException.class)
+ public void testUnionInList() throws Exception {
+ File unioninlist = new File(getClass().getResource("/types/union-in-list/unioninlisttest.yang").toURI());
+ YangContextParser parser = new YangParserImpl();
+ parser.parseFiles(Arrays.asList(unioninlist));
+ }
}