diff --git a/enum.go b/enum.go index 30fc3d8..ee96091 100644 --- a/enum.go +++ b/enum.go @@ -115,10 +115,12 @@ done: // EnumField is part of the body of an Enum. type EnumField struct { - Position scanner.Position - Comment *Comment - Name string - Integer int + Position scanner.Position + Comment *Comment + Name string + Integer int + // ValueOption is deprecated, use Elements instead + ValueOption *Option Elements []Visitee // such as Option and Comment InlineComment *Comment } @@ -165,6 +167,8 @@ func (f *EnumField) parse(p *Parser) error { if err != nil { return err } + // update deprecated field with the last option found + f.ValueOption = o f.Elements = append(f.Elements, o) pos, tok, lit = p.next() if tok == tCOMMA { diff --git a/enum_test.go b/enum_test.go index 2b734d1..5efa381 100644 --- a/enum_test.go +++ b/enum_test.go @@ -75,6 +75,10 @@ enum EnumAllowingAlias { if got, want := ef3opt.Name, "(custom_option)"; got != want { t.Errorf("got [%v] want [%v]", got, want) } + // test for deprecated field + if got, want := ef3opt, ef3.ValueOption; got != want { + t.Errorf("got [%v] want [%v]", got, want) + } if got, want := ef3opt.Constant.Source, "hello world"; got != want { t.Errorf("got [%v] want [%v]", got, want) }