[jira] [Commented] (THRIFT-4195) Compilation to GO produces broken code

2017-05-15 Thread Stanislav Baranov (JIRA)

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

Stanislav Baranov commented on THRIFT-4195:
---

[~allengeorge] [~jensg] Would it be part of 0.11.0 or part of some next pitch 
(e.g 0.10.X) ?
Thank you in advance.

> Compilation to GO produces broken code
> --
>
> Key: THRIFT-4195
> URL: https://issues.apache.org/jira/browse/THRIFT-4195
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Affects Versions: 0.10.0
> Environment: MacOS 10.12.4 (16E195)
> go version go1.8.1 darwin/amd64
>Reporter: Stanislav Baranov
>Priority: Critical
> Attachments: GoUnusedProtection__.go, sample-consts.go, sample.go, 
> sample.thrift
>
>
> Sample source file (see attached sample.thrift):
> {code}
> namespace go reports
> typedef string ReportState
> const ReportState ReportStateQueued = "QUEUED";
> const ReportState ReportStateCalculating = "CALCULATING";
> const ReportState ReportStateImporting = "IMPORTING";
> const ReportState ReportStateFinished = "FINISHED";
> const ReportState ReportStateFailed = "FAILED";
> struct ReportFilter {
> 1: i64 quantity,
> 2: i64 dataVersion,
> 3: string subscriptionID,
> 4: optional string principalID,
> 5: optional string createdOn,
> 6: optional list states,
> }
> {code}
> after compilation as:
> {{thrift -r -v -o ./ -out ./go --gen go:package_prefix="git.4tree.de/" 
> ./sample.thrift}}
> Produces code (see attached sample.go) which contains:
> {code}
> func (p *ReportFilter)  ReadField6(iprot thrift.TProtocol) error {
>   _, size, err := iprot.ReadListBegin()
>   if err != nil {
> return thrift.PrependError("error reading list begin: ", err)
>   }
>   tSlice := make([]ReportState, 0, size)
>   p.States =  tSlice
>   for i := 0; i < size; i ++ {
> var _elem0 string
> if v, err := iprot.ReadString(); err != nil {
> return thrift.PrependError("error reading field 0: ", err)
> } else {
> _elem0 = v
> }
> p.States = append(p.States, _elem0)
>   }
>   if err := iprot.ReadListEnd(); err != nil {
> return thrift.PrependError("error reading list end: ", err)
>   }
>   return nil
> }
> {code}
> When trying to compile this code, GO triggers an error:
> {code}
> cannot use _elem0 (type string) as type ReportState in append
> {code}
> at line:
> {code}
>  p.States = append(p.States, _elem0)
> {code}
> This code compiles normal using  thrift 0.9.3



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (THRIFT-4195) Compilation to GO produces broken code

2017-05-13 Thread Allen George (JIRA)

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

Allen George commented on THRIFT-4195:
--

[~jensg] [~jking3] So, not sure what the correct approach is here. Tested this 
out locally, and it seems like the code in master does the appropriate thing.

> Compilation to GO produces broken code
> --
>
> Key: THRIFT-4195
> URL: https://issues.apache.org/jira/browse/THRIFT-4195
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Affects Versions: 0.10.0
> Environment: MacOS 10.12.4 (16E195)
> go version go1.8.1 darwin/amd64
>Reporter: Stanislav Baranov
>Priority: Critical
> Attachments: GoUnusedProtection__.go, sample-consts.go, sample.go, 
> sample.thrift
>
>
> Sample source file (see attached sample.thrift):
> {code}
> namespace go reports
> typedef string ReportState
> const ReportState ReportStateQueued = "QUEUED";
> const ReportState ReportStateCalculating = "CALCULATING";
> const ReportState ReportStateImporting = "IMPORTING";
> const ReportState ReportStateFinished = "FINISHED";
> const ReportState ReportStateFailed = "FAILED";
> struct ReportFilter {
> 1: i64 quantity,
> 2: i64 dataVersion,
> 3: string subscriptionID,
> 4: optional string principalID,
> 5: optional string createdOn,
> 6: optional list states,
> }
> {code}
> after compilation as:
> {{thrift -r -v -o ./ -out ./go --gen go:package_prefix="git.4tree.de/" 
> ./sample.thrift}}
> Produces code (see attached sample.go) which contains:
> {code}
> func (p *ReportFilter)  ReadField6(iprot thrift.TProtocol) error {
>   _, size, err := iprot.ReadListBegin()
>   if err != nil {
> return thrift.PrependError("error reading list begin: ", err)
>   }
>   tSlice := make([]ReportState, 0, size)
>   p.States =  tSlice
>   for i := 0; i < size; i ++ {
> var _elem0 string
> if v, err := iprot.ReadString(); err != nil {
> return thrift.PrependError("error reading field 0: ", err)
> } else {
> _elem0 = v
> }
> p.States = append(p.States, _elem0)
>   }
>   if err := iprot.ReadListEnd(); err != nil {
> return thrift.PrependError("error reading list end: ", err)
>   }
>   return nil
> }
> {code}
> When trying to compile this code, GO triggers an error:
> {code}
> cannot use _elem0 (type string) as type ReportState in append
> {code}
> at line:
> {code}
>  p.States = append(p.States, _elem0)
> {code}
> This code compiles normal using  thrift 0.9.3



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (THRIFT-4195) Compilation to GO produces broken code

2017-05-12 Thread Allen George (JIRA)

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

Allen George commented on THRIFT-4195:
--

AFAICT, this no longer exists in master. The code is generated correctly with 
the type being wrapped (i.e. converted) to its alias.

> Compilation to GO produces broken code
> --
>
> Key: THRIFT-4195
> URL: https://issues.apache.org/jira/browse/THRIFT-4195
> Project: Thrift
>  Issue Type: Bug
>  Components: Go - Compiler
>Affects Versions: 0.10.0
> Environment: MacOS 10.12.4 (16E195)
> go version go1.8.1 darwin/amd64
>Reporter: Stanislav Baranov
>Priority: Critical
> Attachments: GoUnusedProtection__.go, sample-consts.go, sample.go, 
> sample.thrift
>
>
> Sample source file (see attached sample.thrift):
> {code}
> namespace go reports
> typedef string ReportState
> const ReportState ReportStateQueued = "QUEUED";
> const ReportState ReportStateCalculating = "CALCULATING";
> const ReportState ReportStateImporting = "IMPORTING";
> const ReportState ReportStateFinished = "FINISHED";
> const ReportState ReportStateFailed = "FAILED";
> struct ReportFilter {
> 1: i64 quantity,
> 2: i64 dataVersion,
> 3: string subscriptionID,
> 4: optional string principalID,
> 5: optional string createdOn,
> 6: optional list states,
> }
> {code}
> after compilation as:
> {{thrift -r -v -o ./ -out ./go --gen go:package_prefix="git.4tree.de/" 
> ./sample.thrift}}
> Produces code (see attached sample.go) which contains:
> {code}
> func (p *ReportFilter)  ReadField6(iprot thrift.TProtocol) error {
>   _, size, err := iprot.ReadListBegin()
>   if err != nil {
> return thrift.PrependError("error reading list begin: ", err)
>   }
>   tSlice := make([]ReportState, 0, size)
>   p.States =  tSlice
>   for i := 0; i < size; i ++ {
> var _elem0 string
> if v, err := iprot.ReadString(); err != nil {
> return thrift.PrependError("error reading field 0: ", err)
> } else {
> _elem0 = v
> }
> p.States = append(p.States, _elem0)
>   }
>   if err := iprot.ReadListEnd(); err != nil {
> return thrift.PrependError("error reading list end: ", err)
>   }
>   return nil
> }
> {code}
> When trying to compile this code, GO triggers an error:
> {code}
> cannot use _elem0 (type string) as type ReportState in append
> {code}
> at line:
> {code}
>  p.States = append(p.States, _elem0)
> {code}
> This code compiles normal using  thrift 0.9.3



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)