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

Tom Deering commented on THRIFT-3465:
-------------------------------------

[~jensg], it appears that it does. Will do, thanks!

> Go Code With Complex Const Initializer Compilation Depends On Struct Order
> --------------------------------------------------------------------------
>
>                 Key: THRIFT-3465
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3465
>             Project: Thrift
>          Issue Type: Bug
>          Components: Go - Compiler
>    Affects Versions: 0.9.3
>         Environment: Go 1.4.2
> Thrift 0.9.3
> Ubuntu Linux 14.04
> amd64
>            Reporter: Tom Deering
>              Labels: golang, thrift
>
> Thrift 0.9.3 generates invalid Go code for the following Thrift file:
> {code}
> namespace go bug
> struct Bar {
>       1:list<Foo> foos,
> }
> struct Foo {
>       1:string id,
> }
> const Bar BAR = {
>       "foos": [{
>               "id": "fooID",
>       }]
> }
> {code}
> constants.go
> {code}
> func init() {
>       BAR = &Bar{
>               Foos: []Foo{
>                       &Foo{
>                               ID: "fooID",
>                       }},
>       }
> }
> {code}
> *This is invalid because &Foo is not a Foo.* However, if we flip the order in 
> which Foo and Bar are defined, Thrift 0.9.3 gives us valid Go code:
> {code}
> namespace go no_bug
> struct Foo {
>       1:string id,
> }
> struct Bar {
>       1:list<Foo> foos,
> }
> const Bar BAR = {
>       "foos": [{
>               "id": "fooID",
>       }]
> }
> {code}
> constants.go
> {code}
> func init() {
>       BAR = &Bar{
>               Foos: []*Foo{
>                       &Foo{
>                               ID: "fooID",
>                       }},
>       }
> }
> {code}
> The bug appears to manifest only with use-before-def of structs and a complex 
> initializer containing a field that is a list of the used-before-def'd type. 
> Other kinds of constants (eg list<Foo>) do not seem to expose the bug.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to