Skip to content

Leaf of type union wrongly inherits default and units from typedef #80

Closed
@raghavendramayagundi

Description

As per https://datatracker.ietf.org/doc/html/rfc7950#section-9.12 :
"Any default value or "units" property defined in the member types is not inherited by the union type".

For below example, leaf "leaf-union" is getting "default" (=7) and "units" (=gbp) from the typedef definition:
`typedef new_type_leafref {
type leafref {
path "/root-container/leaf-1";
}
default 7;
units gbp;
description "This is new_type_leafref";
}

container root-container {
	leaf leaf-derived-type {
		type new_type_leafref;
		description "This is leaf-derived-type";
	}
	leaf leaf-union {
		type union {
			type int16;
			type new_type_leafref;
		}
	}
	leaf leaf-1 {
        type int16 {
			range "1..100" {
				error-message "ERROR";
			}
		}
		default 10;
		units initial-units;
		description "This is referenced leaf";
	}
}`

Looks like compile.go => compileType() has to be updated to exclude calling of parent.setDefault() & parent.setUnits() for union type. I am using the latest master version v0.0.0-20230804003402-7593854e7f4d

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions