Subject: [netmod] Can a derived type of instance-identifier change the require-instance property?

From: "Fengchong (frank)" <[email-masked]>
Date: Wed, 15 Dec 2021 06:43:54 +0000

Hi all and martin,

If I have defined a typedef a
typedef a {
  type instance-identifier {
      require-instance false;
  }
}

And then I define another typedef b

typedef b {
  type a {
    require-instance true;
  }

}

Is it correct?

The same scenario is leafref.
本邮件及其附件含有华为公司的保密信息，仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用（包括但不限于全部或部分地泄露、复制、或散发）本邮件中的信息。如果您错收了本邮件，请您立即电话或邮件通知发件人并删除本邮件！
This e-mail and its attachments contain confidential information from HUAWEI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!

---

From: Martin Björklund <[email-masked]>
Date: Wed, 15 Dec 2021 11:10:15 +0100 (CET)

Hi,

> And then I define another typedef b

Yes.  However, it is not clear if this is allowed:

   typedef c {
     type b {
       require-instance false;
     }
   }

Note how section 7.4 in RFC 7950 says:

   The "type" statement takes as an argument a string that is the name
   of a YANG built-in type (see Section 9) or a derived type (see
   Section 7.3), followed by an optional block of substatements that is
   used to put further restrictions on the type.
               ^^^^^^^^^^^^^^^^^^^^

This implies that a subtype cannot expand the value space, which would
make "c" above illegal.

This was the intention, but it could be made more clear.  In many
other cases it is explicitly mentioned, e.g. in 9.4.5:

   If a pattern restriction is applied to a type that is already
   pattern-restricted, values must match all patterns in the base type,
   in addition to the new patterns.

> The same scenario is leafref.

Same answer as above.

/martin