
Booleans are the simplest type in the Swift language.
They’re simply true or false. The most basic language primitive you could imagine.
I was so naïve.
We only see the public interface of the Swift Bool. Much like seeing a sausage made; vivisecting its innards in the source code might put you off forever.
A Frozen Struct
// Bool.swift
@frozen
public struct Bool: Sendable {
// ...That’s right. Like all the basic Swift types you know and love, Bool is a struct masquerading as a native language feature.
It’s marked @frozen — so instance properties can’t be added or removed. This ensures the memory layout (i.e. number of bits) used is constant between Standard Library versions, which is critical for ABI stability.
Bool is Sendable, so the compiler doesn’t throw a fit when you to pass it between threads.
Let’s keep spelunking through the type.
Builtins.Int1
Four lines deep and we hit our second big WTF moment. Sit down and compose yourself.
public struct Bool: Sendable {
@usableFromInline
internal var _value: Builtin.Int1
// ...The Swift Bool lives a double-life. The duplicitous struct has just one instance property — a 1-bit integer.
Think that’s okay? Think again. It isn’t even a real Int!


