I also tried appending .self, as shown in the docs. But I get Type '@Sendable (String, String.Index) -> Lexer.Errors' cannot conform to 'Equatable' (and Error).
I don't think there's any way to express this in Swift, is there?
What is the example doing in this section? It doesn’t show the definition of PizzaToppings.InvalidToppingError.
The self is used to refer to the type, not the associated case or its constructor. So #expect(throws: Lexer.Errors.self) should work.
You can also match a specific value with #expect(throws: Lexer.Errors.invalidToken(s, s.startIndex)), but there currently isn't a way to use wildcards _ like in a switch statement.