Skip to content

YANG Impossible to compare two numbers different types in "must" expression #650

@anikolaev-netgate

Description

@anikolaev-netgate

Hi Olof,
I have met an issue where I was trying to compare two leafs with types uint16 and uint32 with must expression, for example

leaf value-one {
    type uint32;
}
leaf value-two {
    type uint16;
    must "./value-one = current()" {...}
}

Its not possible to compare, it always returs error, even if both values are "0".

RFC7950 says

Note that since all leaf values in the data tree are conceptually
stored in their canonical form (see Section 9.1), any XPath
comparisons are done on the canonical value.

and 9.1 section says

For most types, there is a single canonical representation of the
type's values.  Some types allow multiple lexical representations of
the same value; for example, the positive integer "17" can be
represented as "+17" or "17".  Implementations MUST support all
lexical representations specified in this document.

So for me it looks like there should be no issue with comparing uint16 and uint32.
So I found in clixon function xp_relop is for comparision operators (<, =, >, etc), it tries to compare these two values by function cv_cmp, but cv_cmp returns error if values have different types.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions