summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYuxuan 'fishy' Wang <yuxuan.wang@reddit.com>2022-12-29 15:31:38 -0800
committerYuxuan 'fishy' Wang <fishywang@gmail.com>2023-01-03 10:49:04 -0800
commitb39370ec3bc96d201bbc82fbde136f98ae605ed1 (patch)
tree342d3430fbb2f3550922d5cfcca70b608980ff0d /lib
parent916ae8b8134630f49d32e47c3f0f3218f855a24c (diff)
downloadthrift-b39370ec3bc96d201bbc82fbde136f98ae605ed1.tar.gz
THRIFT-5601: Fix forward typedef in go compiler
Client: go While https://github.com/apache/thrift/pull/951 fixed the bug with forward typedef used in container values, it also introduced a bug that broke forward typedef used in other cases in go code. Limit the fix of it to only the container key and value types to fix other cases.
Diffstat (limited to 'lib')
-rw-r--r--lib/go/test/ForwardTypedef.thrift33
-rw-r--r--lib/go/test/Makefile.am7
2 files changed, 38 insertions, 2 deletions
diff --git a/lib/go/test/ForwardTypedef.thrift b/lib/go/test/ForwardTypedef.thrift
new file mode 100644
index 000000000..4266b7a28
--- /dev/null
+++ b/lib/go/test/ForwardTypedef.thrift
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// https://issues.apache.org/jira/browse/THRIFT-5601
+
+namespace go forwardtypedef
+
+struct Struct {
+ 1: optional Def foo
+ 2: optional Exc bar
+}
+
+typedef i32 Def
+
+exception Exc {
+ 1: optional i32 code
+}
diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am
index 663b42e89..c255a8e48 100644
--- a/lib/go/test/Makefile.am
+++ b/lib/go/test/Makefile.am
@@ -61,7 +61,8 @@ gopath: $(THRIFT) $(THRIFTTEST) \
ConstOptionalField.thrift \
ProcessorMiddlewareTest.thrift \
ClientMiddlewareExceptionTest.thrift \
- ValidateTest.thrift
+ ValidateTest.thrift \
+ ForwardTypedef.thrift
mkdir -p gopath/src
grep -v list.*map.*list.*map $(THRIFTTEST) | grep -v 'set<Insanity>' > ThriftTest.thrift
$(THRIFT) $(THRIFTARGS) -r IncludesTest.thrift
@@ -96,6 +97,7 @@ gopath: $(THRIFT) $(THRIFTTEST) \
$(THRIFT) $(THRIFTARGS_SKIP_REMOTE) ProcessorMiddlewareTest.thrift
$(THRIFT) $(THRIFTARGS) ClientMiddlewareExceptionTest.thrift
$(THRIFT) $(THRIFTARGS) ValidateTest.thrift
+ $(THRIFT) $(THRIFTARGS) ForwardTypedef.thrift
ln -nfs ../../tests gopath/src/tests
cp -r ./dontexportrwtest gopath/src
touch gopath
@@ -121,7 +123,8 @@ check: gopath
./gopath/src/conflictargnamestest \
./gopath/src/processormiddlewaretest \
./gopath/src/clientmiddlewareexceptiontest \
- ./gopath/src/validatetest
+ ./gopath/src/validatetest \
+ ./gopath/src/forwardtypedef
$(GO) test github.com/apache/thrift/lib/go/thrift
$(GO) test ./gopath/src/tests ./gopath/src/dontexportrwtest