diff --git a/include/swift/Demangling/TypeDecoder.h b/include/swift/Demangling/TypeDecoder.h
index 017fd096e0f74..38f125757bcf0 100644
--- a/include/swift/Demangling/TypeDecoder.h
+++ b/include/swift/Demangling/TypeDecoder.h
@@ -693,19 +693,16 @@ class TypeDecoder {
// If the tuple element is labeled, add its label to 'labels'.
unsigned typeChildIndex = 0;
- unsigned nameIdx = 0;
- if (element->getChild(nameIdx)->getKind() == NodeKind::VariadicMarker) {
- variadic = true;
- nameIdx = 1;
- typeChildIndex = 1;
+ if (element->getChild(typeChildIndex)->getKind() == NodeKind::VariadicMarker) {
+ return BuiltType();
}
- if (element->getChild(nameIdx)->getKind() == NodeKind::TupleElementName) {
+ if (element->getChild(typeChildIndex)->getKind() == NodeKind::TupleElementName) {
// Add spaces to terminate all the previous labels if this
// is the first we've seen.
if (labels.empty()) labels.append(elements.size(), ' ');
// Add the label and its terminator.
- labels += element->getChild(0)->getText();
+ labels += element->getChild(typeChildIndex)->getText();
labels += ' ';
typeChildIndex++;
diff --git a/test/Demangle/Inputs/manglings.txt b/test/Demangle/Inputs/manglings.txt
index 877d1dcc9e554..6bc994a37db8f 100644
--- a/test/Demangle/Inputs/manglings.txt
+++ b/test/Demangle/Inputs/manglings.txt
@@ -351,11 +351,12 @@ $sSD5IndexVy__GD ---> $sSD5IndexVy__GD
$s4test3StrCACycfC ---> {T:$s4test3StrCACycfc} test.Str.__allocating_init() -> test.Str
$s18keypaths_inlinable13KeypathStructV8computedSSvpACTKq ---> key path getter for keypaths_inlinable.KeypathStruct.computed : Swift.String : keypaths_inlinable.KeypathStruct, serialized
$s18resilient_protocol24ResilientDerivedProtocolPxAA0c4BaseE0Tn --> associated conformance descriptor for resilient_protocol.ResilientDerivedProtocol.A: resilient_protocol.ResilientBaseProtocol
-$s3red4testyAA3ResOyxSayq_GAEs5ErrorAAq_sAFHD1__HCg_GADyxq_GsAFR_r0_lF --> red.test(red.Res) -> red.Res
+$s3red4testyAA3ResOyxSayq_GAEs5ErrorAAq_sAFHD1__HCg_GADyxq_GsAFR_r0_lF ---> red.test(red.Res) -> red.Res
$s3red4testyAA7OurTypeOy4them05TheirD0Vy5AssocQzGAjE0F8ProtocolAAxAA0c7DerivedH0HD1_AA0c4BaseH0HI1_AieKHA2__HCg_GxmAaLRzlF ---> red.test(A.Type) -> red.OurType>
-$s17property_wrappers10WithTuplesV9fractionsSd_S2dtvpfP --> property wrapper backing initializer of property_wrappers.WithTuples.fractions : (Swift.Double, Swift.Double, Swift.Double)
+$s17property_wrappers10WithTuplesV9fractionsSd_S2dtvpfP ---> property wrapper backing initializer of property_wrappers.WithTuples.fractions : (Swift.Double, Swift.Double, Swift.Double)
$sSo17OS_dispatch_queueC4sync7executeyyyXE_tFTOTA ---> {T:$sSo17OS_dispatch_queueC4sync7executeyyyXE_tFTO} partial apply forwarder for @nonobjc __C.OS_dispatch_queue.sync(execute: () -> ()) -> ()
$sxq_Idgnr_D ---> @differentiable @callee_guaranteed (@in_guaranteed A) -> (@out B)
$sxq_Ilgnr_D ---> @differentiable(linear) @callee_guaranteed (@in_guaranteed A) -> (@out B)
$sS3fIedgyywd_D ---> @escaping @differentiable @callee_guaranteed (@unowned Swift.Float, @unowned @noDerivative Swift.Float) -> (@unowned Swift.Float)
$syQo ---> $syQo
+$sx1td_t ---> (t: A...)
diff --git a/test/TypeDecoder/invalid_types.swift b/test/TypeDecoder/invalid_types.swift
new file mode 100644
index 0000000000000..9f26375b875e0
--- /dev/null
+++ b/test/TypeDecoder/invalid_types.swift
@@ -0,0 +1,12 @@
+// RUN: %empty-directory(%t)
+
+// RUN: %target-build-swift -emit-executable %s -g -o %t/structural_types -emit-module
+// RUN: sed -ne '/\/\/ *DEMANGLE: /s/\/\/ *DEMANGLE: *//p' < %s > %t/input
+// RUN: %lldb-moduleimport-test %t/structural_types -type-from-mangled=%t/input | %FileCheck %s
+
+
+// If this were supported, it would be `(t: τ_0_0...)`
+// But tuples with a variadic 'd' marker are not actually valid Swift types, so
+// the type decoder rejects them.
+// DEMANGLE: $sx1td_t
+// CHECK: Can't resolve type of $sx1td_t