diff --git a/pkg/yang/entry.go b/pkg/yang/entry.go index e2c5309..ce0014e 100644 --- a/pkg/yang/entry.go +++ b/pkg/yang/entry.go @@ -1461,6 +1461,12 @@ func (e *Entry) dup() *Entry { ne.Dir[k] = de } } + + ne.Extra = make(map[string][]interface{}) + for k, v := range e.Extra { + ne.Extra[k] = v + } + return &ne } @@ -1485,6 +1491,9 @@ func (e *Entry) merge(prefix *Value, namespace *Value, oe *Entry) { } else { v.Parent = e v.Exts = append(v.Exts, oe.Exts...) + for lk := range oe.Extra { + v.Extra[lk] = append(v.Extra[lk], oe.Extra[lk]...) + } e.Dir[k] = v } } diff --git a/pkg/yang/entry_test.go b/pkg/yang/entry_test.go index b87d948..2000238 100644 --- a/pkg/yang/entry_test.go +++ b/pkg/yang/entry_test.go @@ -2058,6 +2058,7 @@ var testIfFeatureModules = []struct { feature ft-identity; feature ft-uses; feature ft-refine; + feature ft-augment-uses; container cont { if-feature ft-container; @@ -2118,6 +2119,9 @@ var testIfFeatureModules = []struct { augment "/cont" { if-feature ft-augment; + uses g { + if-feature ft-augment-uses; + } } identity id { @@ -2130,7 +2134,10 @@ var testIfFeatureModules = []struct { if-feature ft-refine; } } - grouping g {} + + grouping g { + container gc {} + } } `, }, @@ -2269,6 +2276,18 @@ func TestIfFeature(t *testing.T) { inIfFeatures: ms.Modules["if-feature"].Uses[0].IfFeature, wantIfFeatures: []string{"ft-uses"}, }, + { + // Verify that if-feature field defined in "uses" is correctly propagated to container + name: "uses", + inIfFeatures: entryIfFeatures(mod.Dir["gc"]), + wantIfFeatures: []string{"ft-uses"}, + }, + { + // Verify that if-feature field defined in "augment" and in "augment > uses" is correctly propagated to container + name: "augment-uses", + inIfFeatures: entryIfFeatures(mod.Dir["cont"].Dir["gc"]), + wantIfFeatures: []string{"ft-augment-uses", "ft-augment"}, + }, } for _, tc := range testcases {