libyang icon indicating copy to clipboard operation
libyang copied to clipboard

Yanglint fails when defining extensions in submodules

Open trentzhou opened this issue 2 years ago • 1 comments

I created a parent module and a sub module like this:

Parent module:

module parent {
  namespace "http://xxx/parent";
  prefix p;

  include sub;

  // BUG: comment the line below, then yanglint fails.
  extension ext1 { description "First extension"; argument arg; }

  container config {
    leaf hostname {
      type string;
      p:ext2 "host name for ext2";
    }
  }
}

The sub module:

submodule sub {
  belongs-to parent {
    prefix p;
  }

  extension ext2 {
    description "Second extension";
    argument arg;
  }

  typedef INTERFACE_NAME {
    description "Interface name";
    type string;
    p:ext2 "interface";
  }
}

If I remove the line extension ext1 from the parent module, then yanglint fails to load the parent module.

> searchpath .
> load parent
libyang[0]: Extension instance "p:ext2" refers "parent" module that does not contain extension definitions.
libyang[0]: Parsing module "parent" failed.
libyang[0]: Loading "parent" module failed.

trentzhou avatar Feb 01 '24 06:02 trentzhou

Fixed.

michalvasko avatar Feb 01 '24 08:02 michalvasko