---
title: Useless conditional statement (UselessConditionalStatement)
framework: swift-compiler
role: article
role_heading: Article
path: swift-compiler/documentation/diagnostics/useless-conditional-statement
---

# Useless conditional statement (UselessConditionalStatement)

Warnings that identify conditional statements (if, while, and guard) whose conditions can never be false.

## Overview

Overview When the condition of an if, while, or guard statement is statically known to always be true, the conditional structure is unnecessary. For if and while, the body always executes (and a while loop with no break would never terminate); for guard, the else branch is unreachable. Examples let x = 0 if case _ = x { // warning: 'if' condition is always true   // ... }

while case _ = x { // warning: 'while' condition is always true   break }

guard case _ = x else { // warning: 'guard' condition is always true, body is unreachable   fatalError() } In the examples above, the pattern matching conditions (case _ = ...) can never fail.

## See Also

### Related Documentation

- [If Statement](swift-compiler/documentation/swift-book/documentation/the-swift-programming-language/statements.md)
- [Guard Statement](swift-compiler/documentation/swift-book/documentation/the-swift-programming-language/statements.md)
- [While Statement](swift-compiler/documentation/swift-book/documentation/the-swift-programming-language/statements.md)

- [@dynamicCallable implementation requirements (DynamicCallable)](swift-compiler/documentation/diagnostics/dynamic-callable-requirements.md)
- [Add @preconcurrency import (AddPreconcurrencyImport)](swift-compiler/documentation/diagnostics/add-preconcurrency-import.md)
- [Always enabled availability domains (AlwaysAvailableDomain)](swift-compiler/documentation/diagnostics/always-available-domain.md)
- [Argument matching for trailing closures (TrailingClosureMatching)](swift-compiler/documentation/diagnostics/trailing-closure-matching.md)
- [Calling a mutating async actor-isolated method (ActorIsolatedMutatingAsync)](swift-compiler/documentation/diagnostics/actor-isolated-mutating-async.md)
- [Calling an actor-isolated method from a synchronous nonisolated context (ActorIsolatedCall)](swift-compiler/documentation/diagnostics/actor-isolated-call.md)
- [Captures in a `@Sendable` closure (SendableClosureCaptures)](swift-compiler/documentation/diagnostics/sendable-closure-captures.md)
- [Compilation caching (CompilationCaching)](swift-compiler/documentation/diagnostics/compilation-caching.md)
- [Conforming to `StringInterpolationProtocol` (StringInterpolationConformance)](swift-compiler/documentation/diagnostics/string-interpolation-conformance.md)
- [Conversion from `@isolated(any)` function type to synchronous function type (ConversionFromIsolatedAnyToSynchronous)](swift-compiler/documentation/diagnostics/conversion-from-isolated-any-to-synchronous.md)
- [Cross-isolation data race (RegionIsolationCrossIsolationDataRace)](swift-compiler/documentation/diagnostics/region-isolation-cross-isolation-data-race.md)
- [Deprecated declaration warnings (DeprecatedDeclaration)](swift-compiler/documentation/diagnostics/deprecated-declaration.md)
- [Deprecated implementation-only imports (ImplementationOnlyDeprecated)](swift-compiler/documentation/diagnostics/implementation-only-deprecated.md)
- [Dynamic exclusivity (DynamicExclusivity)](swift-compiler/documentation/diagnostics/dynamic-exclusivity.md)
- [Embedded Swift language restrictions (EmbeddedRestrictions)](swift-compiler/documentation/diagnostics/embedded-restrictions.md)
