diff --git a/meta/core_gen.go b/meta/core_gen.go index 61d866ee..3b0ce73a 100644 --- a/meta/core_gen.go +++ b/meta/core_gen.go @@ -1671,8 +1671,10 @@ func (m *LeafList) DefaultValue() interface{} { func (m *LeafList) setDefaultValue(d interface{}) { if s, valid := d.([]string); valid { m.defaultVals = s + } else if s, valid := d.(string); valid { + m.defaultVals = []string{s} } else { - panic("expected []string") + panic("expected []string or string") } } @@ -2281,8 +2283,10 @@ func (m *Refine) DefaultValue() interface{} { func (m *Refine) setDefaultValue(d interface{}) { if s, valid := d.([]string); valid { m.defaultVals = s + } else if s, valid := d.(string); valid { + m.defaultVals = []string{s} } else { - panic("expected []string") + panic("expected []string or string") } } @@ -3351,8 +3355,10 @@ func (m *AddDeviate) DefaultValue() interface{} { func (m *AddDeviate) setDefaultValue(d interface{}) { if s, valid := d.([]string); valid { m.defaultVals = s + } else if s, valid := d.(string); valid { + m.defaultVals = []string{s} } else { - panic("expected []string") + panic("expected []string or string") } } @@ -3473,8 +3479,10 @@ func (m *ReplaceDeviate) DefaultValue() interface{} { func (m *ReplaceDeviate) setDefaultValue(d interface{}) { if s, valid := d.([]string); valid { m.defaultVals = s + } else if s, valid := d.(string); valid { + m.defaultVals = []string{s} } else { - panic("expected []string") + panic("expected []string or string") } } @@ -3556,8 +3564,10 @@ func (m *DeleteDeviate) DefaultValue() interface{} { func (m *DeleteDeviate) setDefaultValue(d interface{}) { if s, valid := d.([]string); valid { m.defaultVals = s + } else if s, valid := d.(string); valid { + m.defaultVals = []string{s} } else { - panic("expected []string") + panic("expected []string or string") } } diff --git a/meta/core_gen.in b/meta/core_gen.in index f6fdfed5..c20a545f 100644 --- a/meta/core_gen.in +++ b/meta/core_gen.in @@ -466,8 +466,10 @@ func (m *{{.Name}}) DefaultValue() interface{} { func (m *{{.Name}}) setDefaultValue(d interface{}) { if s, valid := d.([]string); valid { m.defaultVals = s + } else if s, valid := d.(string); valid { + m.defaultVals = []string{s} } else { - panic("expected []string") + panic("expected []string or string") } } diff --git a/parser/testdata/typedef/gold/typedef-x.json b/parser/testdata/typedef/gold/typedef-x.json index f5e2d81e..52c20105 100644 --- a/parser/testdata/typedef/gold/typedef-x.json +++ b/parser/testdata/typedef/gold/typedef-x.json @@ -14,4 +14,11 @@ "range":"-11.111..22.222", "errorMessage":"This is an error-message for range in typedef"}], "fractionDigits":4, - "format":"decimal64"}}}]}} \ No newline at end of file + "format":"decimal64"}}}, + { + "ident":"l", + "leaf-list":{ + "default":"[7]", + "type":{ + "ident":"ls", + "format":"stringList"}}}]}} \ No newline at end of file diff --git a/parser/testdata/typedef/gold/typedef-x.lex b/parser/testdata/typedef/gold/typedef-x.lex index bede6288..e1d03cef 100644 --- a/parser/testdata/typedef/gold/typedef-x.lex +++ b/parser/testdata/typedef/gold/typedef-x.lex @@ -32,4 +32,21 @@ description "descriptio"... [string] "\"This is l"... ; ";" } "}" +typedef "typedef" +[ident] "ls" +{ "{" +type "type" +[ident] "string" +; ";" +default "default" +[string] "7" +; ";" +} "}" +leaf-list "leaf-list" +[ident] "l" +{ "{" +type "type" +[ident] "ls" +; ";" +} "}" } "}" diff --git a/parser/testdata/typedef/typedef-x.yang b/parser/testdata/typedef/typedef-x.yang index 1cd57c1c..a48c73aa 100644 --- a/parser/testdata/typedef/typedef-x.yang +++ b/parser/testdata/typedef/typedef-x.yang @@ -15,4 +15,13 @@ module typedef-x { type new_type_decimal; description "This is leaf-derived-type"; } + + typedef ls { + type string ; + default 7; + } + + leaf-list l { + type ls; + } } \ No newline at end of file