<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Never",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s5NeverO"
  },
  "title" : "Never"
}
-->

# Never

A type that has no values and can’t be constructed.

```
@frozen enum Never
```

## Overview

Use `Never` as the return type of a function
that doesn’t return normally — for example,
because it runs forever or terminates the program.

```
// An infinite loop never returns.
func forever() -> Never {
    while true {
        print("I will print forever.")
    }
}

// Calling fatalError(_:file:line:) unconditionally stops the program.
func crashAndBurn() -> Never {
    fatalError("Something very, very bad happened")
}
```

A function that returns `Never` is called a *nonreturning* function.
Closures, methods, computed properties, and subscripts
can also be nonreturning.

There’s no way to create an instance of `Never`;
this characteristic makes it an *uninhabited* type.
You can use an uninhabited type like `Never`
to represent states in your program
that are impossible to reach during execution.
Swift’s type system uses this information —
for example, to reason about control statements
in cases that are known to be unreachable.

```
let favoriteNumber: Result<Int, Never> = .success(42)
switch favoriteNumber {
case .success(let value):
    print("My favorite number is", value)
}
```

In the code above,
`favoriteNumber` has a failure type of `Never`,
indicating that it always succeeds.
The switch statement is therefore exhaustive,
even though it doesn’t contain a `.failure` case,
because that case could never be reached.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)