Skip to content

Commit a94b2dd

Browse files
authored
Merge pull request #6780 from xedin/keypath-crashers
[QoI] Cleanup AST after trying to shrink constraint system of invalid expression
2 parents 4135426 + 9b7d632 commit a94b2dd

12 files changed

+24
-23
lines changed

Diff for: lib/Sema/CSSolver.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,7 @@ bool ConstraintSystem::Candidate::solve() {
14531453
// because it would assign types to expressions, which
14541454
// might interfere with solving higher-level expressions.
14551455
ExprCleaner cleaner(E);
1456+
CleanupIllFormedExpressionRAII cleanup(TC.Context, E);
14561457

14571458
// Allocate new constraint system for sub-expression.
14581459
ConstraintSystem cs(TC, DC, None);
@@ -1495,6 +1496,18 @@ bool ConstraintSystem::Candidate::solve() {
14951496

14961497
// Record found solutions as suggestions.
14971498
this->applySolutions(solutions);
1499+
1500+
// Solution application is going to modify AST, so we need to avoid
1501+
// clean-up, but let's double-check if we have any implicit
1502+
// expressions with type variables and nullify their types.
1503+
cleanup.disable();
1504+
E->forEachChildExpr([&](Expr *childExpr) -> Expr * {
1505+
Type type = childExpr->getType();
1506+
if (childExpr->isImplicit() && type && type->hasTypeVariable())
1507+
childExpr->setType(Type());
1508+
return childExpr;
1509+
});
1510+
14981511
return false;
14991512
}
15001513

Diff for: validation-test/compiler_crashers/28593-unreachable-executed-at-swift-lib-ast-type-cpp-3771.swift renamed to validation-test/compiler_crashers_fixed/28593-unreachable-executed-at-swift-lib-ast-type-cpp-3771.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// REQUIRES: deterministic-behavior
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
[{_=#keyPath(t>w

Diff for: validation-test/compiler_crashers/28623-swift-tupletype-get-llvm-arrayref-swift-tupletypeelt-swift-astcontext-const.swift renamed to validation-test/compiler_crashers_fixed/28623-swift-tupletype-get-llvm-arrayref-swift-tupletypeelt-swift-astcontext-const.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// REQUIRES: deterministic-behavior
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
f#keyPath(n&_==a>c{{{{{{{{{{{{{{{{{_=b:{{{{c{{{{{{d

Diff for: validation-test/compiler_crashers/28631-unreachable-executed-at-swift-lib-ast-type-cpp-1130.swift renamed to validation-test/compiler_crashers_fixed/28631-unreachable-executed-at-swift-lib-ast-type-cpp-1130.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// REQUIRES: deterministic-behavior
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
[{{{{{{{{{{{{{{0=#keyPath(n&_=d

Diff for: validation-test/compiler_crashers/28632-unreachable-executed-at-swift-lib-ast-type-cpp-1130.swift renamed to validation-test/compiler_crashers_fixed/28632-unreachable-executed-at-swift-lib-ast-type-cpp-1130.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// REQUIRES: deterministic-behavior
98
// REQUIRES: asserts
10-
// RUN: not --crash %target-swift-frontend %s -emit-ir
9+
// RUN: not %target-swift-frontend %s -emit-ir
1110

1211
{func a>
1312
print(a==#keyPath(a{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{

Diff for: validation-test/compiler_crashers/28635-swift-tupletype-get-llvm-arrayref-swift-tupletypeelt-swift-astcontext-const.swift renamed to validation-test/compiler_crashers_fixed/28635-swift-tupletype-get-llvm-arrayref-swift-tupletypeelt-swift-astcontext-const.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// REQUIRES: deterministic-behavior
9-
// REQUIRES: deterministic-behavior
10-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
119
func a|Set(#keyPath(t>a>a{

Diff for: validation-test/compiler_crashers/28639-unreachable-executed-at-swift-lib-ast-type-cpp-1337.swift renamed to validation-test/compiler_crashers_fixed/28639-unreachable-executed-at-swift-lib-ast-type-cpp-1337.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// REQUIRES: deterministic-behavior
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
print([{#keyPath(a}(t>A

Diff for: validation-test/compiler_crashers/28640-swift-tupletype-get-llvm-arrayref-swift-tupletypeelt-swift-astcontext-const.swift renamed to validation-test/compiler_crashers_fixed/28640-swift-tupletype-get-llvm-arrayref-swift-tupletypeelt-swift-astcontext-const.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// REQUIRES: deterministic-behavior
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
protocol a func a|Set(#keyPath(t>a{

Diff for: validation-test/compiler_crashers/28641-result-case-not-implemented.swift renamed to validation-test/compiler_crashers_fixed/28641-result-case-not-implemented.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// REQUIRES: deterministic-behavior
98
// REQUIRES: asserts
10-
// RUN: not --crash %target-swift-frontend %s -emit-ir
9+
// RUN: not %target-swift-frontend %s -emit-ir
1110
{let β=b&[{{{#keyPath(n&[{{{{{{{{{{{{{{{{{{{{{{{{{{a{{{{s

Diff for: validation-test/compiler_crashers/28642-swift-optionaltype-get-swift-type.swift renamed to validation-test/compiler_crashers_fixed/28642-swift-optionaltype-get-swift-type.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// REQUIRES: deterministic-behavior
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
Array(_==#keyPath(t>Void!

Diff for: validation-test/compiler_crashers/28645-swift-type-transform-llvm-function-ref-swift-type-swift-type-const.swift renamed to validation-test/compiler_crashers_fixed/28645-swift-type-transform-llvm-function-ref-swift-type-swift-type-const.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// REQUIRES: deterministic-behavior
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
(.n).h.n&[(#keyPath(t>A

Diff for: validation-test/compiler_crashers/28646-swift-lvaluetype-get-swift-type.swift renamed to validation-test/compiler_crashers_fixed/28646-swift-lvaluetype-get-swift-type.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// REQUIRES: deterministic-behavior
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
#keyPath(a
1110
print(Int
1211
print(_=#keyPath(a

0 commit comments

Comments
 (0)