diff --git a/semantic/checker.go b/semantic/checker.go index 40f07874..de929723 100644 --- a/semantic/checker.go +++ b/semantic/checker.go @@ -145,11 +145,28 @@ func (c *checker) CheckStructLikes(t *parser.Thrift) (warns []string, err error) warns = append(warns, fmt.Sprintf("non-positive ID %d of field %q in %q", f.ID, f.Name, s.Name)) } + if containByteType(f.Type) { + warns = append(warns, fmt.Sprintf("field %q in %q is still using 'byte'. The 'byte' type is a compatibility alias for 'i8'. Use 'i8' to emphasize the signedness of this type. If you want to generate '[]byte', please use 'binary' in thrift IDL.", + f.Name, s.Name)) + } } } return } +func containByteType(t *parser.Type) bool { + if parser.Typename2TypeID(t.Name) == parser.BYTE { + return true + } + if t.KeyType != nil && containByteType(t.KeyType) { + return true + } + if t.ValueType != nil && containByteType(t.ValueType) { + return true + } + return false +} + // CheckUnions checks the semantics of union nodes. func (c *checker) CheckUnions(t *parser.Thrift) (warns []string, err error) { for _, u := range t.Unions { diff --git a/version/version.go b/version/version.go index 20fcf801..a68f9439 100644 --- a/version/version.go +++ b/version/version.go @@ -14,4 +14,4 @@ package version -const ThriftgoVersion = "0.3.18" +const ThriftgoVersion = "0.3.19"