[ https://issues.apache.org/jira/browse/THRIFT-5685?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Yuxuan Wang updated THRIFT-5685: -------------------------------- Description: This is a bug introduced by the fix of THRIFT-5601. Given this thrift file: {code:java} struct Bar { 1: optional Foo bar } struct Foo { 1: optional i64 foo } {code} 0.18.0 with b39370ec3bc96d2 reverted will generate the following go code (expected): {code:go} ... var Bar_Bar_DEFAULT *Foo func (p *Bar) GetBar() *Foo { if !p.IsSetBar() { return Bar_Bar_DEFAULT } return p.Bar } ... {code} while 0.18.0 generates: {code:go} ... var Bar_Bar_DEFAULT Foo func (p *Bar) GetBar() Foo { if !p.IsSetBar() { return Bar_Bar_DEFAULT } return *p.Bar } ... {code} This makes usages like bar.GetBar().GetFoo() no longer compiles because GetBar now returns non-pointer type. was: This is a bug introduced by the fix of THRIFT-5601. Given this thrift file: {code:java} struct Bar { 1: optional Foo bar } struct Foo { 1: optional i64 foo } {code} 0.18.0 with b39370ec3bc96d2 reverted will generate the following go code (expected): {code:go} ... -var Bar_Bar_DEFAULT *Foo -func (p *Bar) GetBar() *Foo { if !p.IsSetBar() { return Bar_Bar_DEFAULT } return p.Bar } ... {code} while 0.18.0 generates: {code:go} ... var Bar_Bar_DEFAULT Foo func (p *Bar) GetBar() Foo { if !p.IsSetBar() { return Bar_Bar_DEFAULT } return *p.Bar } ... {code} This makes usages like bar.GetBar().GetFoo() no longer compiles because GetBar now returns non-pointer type. > Compiler generates wrong go code for forward defined types in optional fields > ----------------------------------------------------------------------------- > > Key: THRIFT-5685 > URL: https://issues.apache.org/jira/browse/THRIFT-5685 > Project: Thrift > Issue Type: Bug > Components: Go - Compiler > Affects Versions: 0.18.0 > Reporter: Yuxuan Wang > Assignee: Yuxuan Wang > Priority: Major > > This is a bug introduced by the fix of THRIFT-5601. > Given this thrift file: > {code:java} > struct Bar { > 1: optional Foo bar > } > struct Foo { > 1: optional i64 foo > } > {code} > 0.18.0 with b39370ec3bc96d2 reverted will generate the following go code > (expected): > {code:go} > ... > var Bar_Bar_DEFAULT *Foo > func (p *Bar) GetBar() *Foo { > if !p.IsSetBar() { > return Bar_Bar_DEFAULT > } > return p.Bar > } > ... > {code} > while 0.18.0 generates: > {code:go} > ... > var Bar_Bar_DEFAULT Foo > func (p *Bar) GetBar() Foo { > if !p.IsSetBar() { > return Bar_Bar_DEFAULT > } > return *p.Bar > } > ... > {code} > This makes usages like bar.GetBar().GetFoo() no longer compiles because > GetBar now returns non-pointer type. -- This message was sent by Atlassian Jira (v8.20.10#820010)