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

Sylwester Lachiewicz commented on THRIFT-5463:
----------------------------------------------

The first item still reproduces with the released 0.24.0 compiler: a constant 
of a struct whose optional container field has a default value renders the 
container as a plain literal, and the consts file fails with {{cannot use 
[]int32{...} as *[]int32 value in struct literal}}. [PR 
#3856|https://github.com/apache/thrift/pull/3856] addresses that half: the 
list, set and map branches of {{render_const_value}} now take the address of 
the literal, using the typedef name where the field has one, with tests for 
plain, typedef and struct-keyed containers. The second item, strings with 
defaults staying values while containers with defaults become pointers, is left 
as is since changing it renames generated fields.

_This comment was created with AI assistance._

> Incorrect and inconsistency in compiler generated go code regarding pointer 
> types
> ---------------------------------------------------------------------------------
>
>                 Key: THRIFT-5463
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5463
>             Project: Thrift
>          Issue Type: Bug
>          Components: Go - Compiler
>    Affects Versions: 0.15.0, 0.14.2
>            Reporter: Yuxuan Wang
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> This is the continuation/followup from THRIFT-5389 and THRIFT-5461.
>  # For container fields of a struct (map/list/set), we make the container 
> type a point when it has default value set, but we didn't handle that 
> correctly when generating the constant value (part of THRIFT-3289 but missed 
> from the fix)
>  # The decision on whether to make string/binary fields of a struct's type a 
> pointer is inconsistent from container types. For container types we make it 
> a pointer when it has a default value, so we determine IsSet* by checking if 
> the pointer is nil. But for string we make it not a pointer when it has 
> default value, and determine IsSet* by checking if the value is the same as 
> the default. We should make them consistent.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to