[ 
https://issues.apache.org/jira/browse/THRIFT-6338?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jens Geyer resolved THRIFT-6338.
--------------------------------
    Fix Version/s: 0.26.0
         Assignee: Sylwester Lachiewicz
       Resolution: Fixed

> Smalltalk generator emits every enum twice
> ------------------------------------------
>
>                 Key: THRIFT-6338
>                 URL: https://issues.apache.org/jira/browse/THRIFT-6338
>             Project: Thrift
>          Issue Type: Bug
>          Components: Smalltalk - Compiler
>    Affects Versions: 0.25.0
>            Reporter: Sylwester Lachiewicz
>            Assignee: Sylwester Lachiewicz
>            Priority: Minor
>             Fix For: 0.26.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {{--gen st}} writes each enum's definition twice, back to back. 
> [t_st_generator::init_generator|https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_st_generator.cc#L185]
>  loops over the program's enums and calls {{generate_enum}}, and then 
> [t_generator::generate_program|https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_generator.cc#L38]
>  loops over them again, as it does for every generator.
> {code}
> enum Op { ADD = 1, SUB = 2 }
> {code}
> {noformat}
> $ thrift --gen st repro.thrift && grep -n "enums at: 'Op'" gen-st/repro.st
> 34:Repro enums at: 'Op' put: [(Dictionary new 
> 39:Repro enums at: 'Op' put: [(Dictionary new 
> {noformat}
> Harmless at runtime because the second {{at:put:}} replaces the first, but it 
> doubles the enum section of every generated file. The fix is to drop the loop 
> in {{init_generator}}. Reproduced on master at 3af0cfff1.



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

Reply via email to