Skip to content

Commit dced34a

Browse files
authored
Merge pull request #8059 from CodaFi/initial-value-problem
2 parents 5c0165f + 1367b0c commit dced34a

File tree

25 files changed

+31
-32
lines changed

25 files changed

+31
-32
lines changed

lib/Sema/TypeCheckStmt.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,10 +1441,14 @@ static void checkDefaultArguments(TypeChecker &tc,
14411441
->changeResilienceExpansion(expansion);
14421442

14431443
// Type-check the initializer, then flag that we did so.
1444-
if (!tc.typeCheckExpression(e, initContext,
1445-
TypeLoc::withoutLoc(param->getType()),
1446-
CTP_DefaultParameter))
1444+
bool hadError = tc.typeCheckExpression(e, initContext,
1445+
TypeLoc::withoutLoc(param->getType()),
1446+
CTP_DefaultParameter);
1447+
if (!hadError) {
14471448
param->setDefaultValue(e);
1449+
} else {
1450+
param->setDefaultValue(nullptr);
1451+
}
14481452

14491453
tc.checkInitializerErrorHandling(initContext, e);
14501454

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
func t(UInt=1 + 1 as?Int){

validation-test/compiler_crashers/28656-unreachable-executed-at-swift-lib-ast-type-cpp-1137.swift renamed to validation-test/compiler_crashers_fixed/28656-unreachable-executed-at-swift-lib-ast-type-cpp-1137.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
{ struct A{
1010
p.init(UInt=1 + 1 as?Int){

validation-test/compiler_crashers/28658-result-case-not-implemented.swift renamed to validation-test/compiler_crashers_fixed/28658-result-case-not-implemented.swift

Lines changed: 1 addition & 2 deletions
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: asserts
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
s a){func a(UInt=1 + 1 + 1 as?Int){

validation-test/compiler_crashers/28661-swift-typebase-getcanonicaltype.swift renamed to validation-test/compiler_crashers_fixed/28661-swift-typebase-getcanonicaltype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
{func b(UInt=1 + 1 + 1 as?Int?){class d a{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
let x[{{{{{{{{{{{{{{{{{{{{{{{{struct c{func b(UInt=1 + 1 + 1 + 1 + 1 as?Int){{{{{{{{{{{{struct P

validation-test/compiler_crashers/28676-currentconstraintsolverarena-no-constraint-solver-active.swift renamed to validation-test/compiler_crashers_fixed/28676-currentconstraintsolverarena-no-constraint-solver-active.swift

Lines changed: 1 addition & 2 deletions
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: asserts
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
nt){{func t(UInt=1 + 1 + 1 as?Int){{{{{[._{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
{{{{{{{func t(UInt=1 + 1 as?Int){{{{

validation-test/compiler_crashers/28679-swift-typebase-getcanonicaltype.swift renamed to validation-test/compiler_crashers_fixed/28679-swift-typebase-getcanonicaltype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
{struct A{func b(UInt=1 + 1 + 1 as?Int){{{

validation-test/compiler_crashers/28681-swift-typebase-getcanonicaltype.swift renamed to validation-test/compiler_crashers_fixed/28681-swift-typebase-getcanonicaltype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
d}func a(UInt=1 + 1 as?Int){{{{{{{{{{{{func b(UInt=1 + 1 + 1 + 1 as?Int){{{{{{{{{{{{{{(a{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
Lines changed: 1 addition & 2 deletions
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: asserts
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
{{{func t(UInt=1 + 1 + 1 + 1 as?Int){{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{$0{{{{{{{{{{{{{{{{{{{{{{{{
Lines changed: 1 addition & 2 deletions
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: asserts
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
{struct A{func b(UInt=1 + 1 as?Int){{

validation-test/compiler_crashers/28692-unreachable-executed-at-swift-lib-ast-type-cpp-1349.swift renamed to validation-test/compiler_crashers_fixed/28692-unreachable-executed-at-swift-lib-ast-type-cpp-1349.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
{==a
1010
extension{func c(UInt=1 + 1 + 1 + 1 as?Int){

validation-test/compiler_crashers/28695-unreachable-executed-at-swift-lib-ast-type-cpp-1351.swift renamed to validation-test/compiler_crashers_fixed/28695-unreachable-executed-at-swift-lib-ast-type-cpp-1351.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
u
1010
func o(UInt=1 + 1 as?Int){r

validation-test/compiler_crashers/28696-swift-typebase-getcanonicaltype.swift renamed to validation-test/compiler_crashers_fixed/28696-swift-typebase-getcanonicaltype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
{func b(UInt=1 + 1 + 1 + 1 + 1 as?Int){a

validation-test/compiler_crashers/28699-swift-typebase-getcanonicaltype.swift renamed to validation-test/compiler_crashers_fixed/28699-swift-typebase-getcanonicaltype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
==1 C:{func b(UInt=1 + 1 + 1 as?Int){a==A(

validation-test/compiler_crashers/28703-swift-typebase-getdesugaredtype.swift renamed to validation-test/compiler_crashers_fixed/28703-swift-typebase-getdesugaredtype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
func b(UInt=1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 as?Int){a

validation-test/compiler_crashers/28705-swift-typebase-getcanonicaltype.swift renamed to validation-test/compiler_crashers_fixed/28705-swift-typebase-getcanonicaltype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
{
1010
struct c{}func t(UInt= 1 + 1 + 1 + 1 as?Int){
1111
{{

validation-test/compiler_crashers/28709-unreachable-executed-at-swift-lib-ast-type-cpp-1005.swift renamed to validation-test/compiler_crashers_fixed/28709-unreachable-executed-at-swift-lib-ast-type-cpp-1005.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
{
1010
class C{func o(UInt=1 + 1 + 1 + 1 + 1 as?Int){{
1111
{r
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
{struct A{func a(UInt=1 + 1 + 1 + 1 as?Int){{
1010
protocol r
1111
protocol A

validation-test/compiler_crashers/28712-swift-typebase-getcanonicaltype.swift renamed to validation-test/compiler_crashers_fixed/28712-swift-typebase-getcanonicaltype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
{struct B{func o(UInt=_=1 + 1 + 1 + 1 as?Int){a f{{A

validation-test/compiler_crashers/28713-swift-typebase-getdesugaredtype.swift renamed to validation-test/compiler_crashers_fixed/28713-swift-typebase-getdesugaredtype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
struct A{
1010
func a
1111
func o(UInt=1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 as?Int){a f=1 1?{_=(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
a<
1010
func a
1111
{

validation-test/compiler_crashers/28716-unreachable-executed-at-swift-lib-ast-type-cpp-1215.swift renamed to validation-test/compiler_crashers_fixed/28716-unreachable-executed-at-swift-lib-ast-type-cpp-1215.swift

Lines changed: 1 addition & 2 deletions
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: OS=linux-gnu
9-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
109
func o(UInt=_=1 + 1 t){a

validation-test/compiler_crashers/28718-swift-typebase-getcanonicaltype.swift renamed to validation-test/compiler_crashers_fixed/28718-swift-typebase-getcanonicaltype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +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-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
n
1010
func{(struct A{func b(Int=1 + 1 + 1 as?Int?){a

0 commit comments

Comments
 (0)