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

ASF GitHub Bot commented on THRIFT-3465:
----------------------------------------

GitHub user tylertreat opened a pull request:

    https://github.com/apache/thrift/pull/919

    THRIFT-3465 Go Code With Complex Const Initializer Compilation Depends On 
Struct Order

    https://issues.apache.org/jira/browse/THRIFT-3465
    https://issues.apache.org/jira/browse/THRIFT-3553
    
    @markerickson-wf 
    @tomdeering-wf
    @mattsanders-wf

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/tylertreat/thrift THRIFT-3465

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/919.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #919
    
----
commit bbaa8cdc75f4a4ac63786617cda2c8667172d4be
Author: Tyler Treat <[email protected]>
Date:   2016-03-04T06:00:42Z

    THRIFT-3465 Go Code With Complex Const Initializer Compilation Depends
    On Struct Order

----


> 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