You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[TypeChecker] Diagnose empty switch statements in function builder bodies
If there are no 'case' statements in the body let's try
to diagnose this situation via limited exhaustiveness check
before failing a builder transform, otherwise type-checker
might end up without any diagnostics which leads to crashes
in SILGen.
Resolves: rdar://problem/65983237
(cherry picked from commit 0cac079)
Copy file name to clipboardExpand all lines: test/Constraints/function_builder_diags.swift
+18Lines changed: 18 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -584,4 +584,22 @@ struct MyView {
584
584
// expected-note@-1 {{opaque return type declared here}}
585
585
DoesNotConform()
586
586
}
587
+
588
+
@TupleBuildervaremptySwitch:someP{
589
+
switchOptional.some(1){ // expected-error {{'switch' statement body must have at least one 'case' or 'default' block; do you want to add a default case?}}
590
+
}
591
+
}
592
+
593
+
@TupleBuildervarinvalidSwitchOne:someP{
594
+
switchOptional.some(1){
595
+
case . // expected-error {{expected ':' after 'case'}}
596
+
} // expected-error {{expected identifier after '.' expression}}
597
+
}
598
+
599
+
@TupleBuildervarinvalidSwitchMultiple:someP{
600
+
switchOptional.some(1){
601
+
case.none: // expected-error {{'case' label in a 'switch' should have at least one executable statement}}
602
+
case . // expected-error {{expected ':' after 'case'}}
603
+
} // expected-error {{expected identifier after '.' expression}}
0 commit comments