Yes, there are several places in the Swift Programming Language documentation that could benefit from a proper "error" highlight. For example, here are a few code blocks that illustrate errors using plain text comments in the code:
-
in the Opaque and Boxed Protocol Types documentation:
func invalidFlip<T: Shape>(_ shape: T) -> some Shape { if shape is Square { return shape // Error: return types don't match } return FlippedShape(shape: shape) // Error: return types don't match }
-
in the Memory safety documentation:
var stepSize = 1 func increment(_ number: inout Int) { number += stepSize } increment(&stepSize) // Error: conflicting accesses to stepSize
-
in the Generics documentation:
func f<MyType>(x: inout MyType) { let x1 = x // The value of x1 is a copy of x's value. let x2 = x // The value of x2 is a copy of x's value. } func g<AnotherType: ~Copyable>(y: inout AnotherType) { let y1 = y // The assignment consumes y's value. let y2 = y // Error: Value consumed more than once. }