Sylwester Lachiewicz created THRIFT-6338:
--------------------------------------------
Summary: 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
{{--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)