[ 
https://issues.apache.org/jira/browse/THRIFT-5461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17412214#comment-17412214
 ] 

Yuxuan Wang commented on THRIFT-5461:
-------------------------------------

While trying to fix this I discovered another issue we need to fix as well.

When we have a optional binary field, we never generate the go code with point. 
e.g.:
{code:java}
struct OptionalBinary {
  1: optional binary bin
}{code}
generates:
{code:java}
type OptionalBinary struct { 
  Bin []byte `...`
}{code}
but when using optional containers we generate pointer types. e.g.:
{code:java}
struct OptionalStringList {
  1: optional list<string> str
}{code}
generates:
{code:java}
type OptionalStringList struct {
  Str *[]string `...`
}{code}
This actually breaks the fix for THRIFT-5389, because we never generate those 
-Ptr helpers for container types (we cannot create those helpers). We need to 
stop making pointer containers.

Because of this issue, the fix is much larger than my original estimation. We 
likely won't have enough time to fix it before 0.15.0, it will be fixed in 
0.16.0 instead.

> Invalid golang code generated for optional set<binary> with a default value
> ---------------------------------------------------------------------------
>
>                 Key: THRIFT-5461
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5461
>             Project: Thrift
>          Issue Type: Bug
>          Components: Go - Compiler
>    Affects Versions: 0.15.0, 0.14.2
>            Reporter: Yuri Melnikov
>            Priority: Major
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> There's a bug in the Thrift Go generator that happens when an optional 
> set<bynary> is used with a default value. For example, a simple struct like 
> this:
> {code:java}
> struct OptionalSetBinary {
>   1: optional set<binary> bin = {}
> }
> {code}
> ...generates a default value like this:
> {code:go}
> var OptionalSetBinary_Bin_DEFAULT [][]byte = []string{
> }
> {code}
> ...and fails the compilation of the unit-test:
> {code:java}
> ../src/gen/thrifttest/ThriftTest.go:5620:5: cannot use []string{} (type 
> []string) as type [][]byte in assignment
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to