#if DEBUG in Swift

Sigh. The Swift team give an impeccable impression of a group of people who’ve never actually tried to use Swift. An incredibly basic compiler task is to provide code a way to distinguish between debug & release builds, in order that it can behave accordingly (e.g. change the default logging verbosity, change asserts from fatal to … Read more

Stupid Swift error message #a bajillion and one

Input code: let componentsOfPotentialInterest = [Calendar.Component: ((Int) -> String)]( .day: { String($0 + 1) }, ) Push button.  Expect results (or at least bacon).  Get: Foo.swift:76:21: error: expected ‘,’ separator .day: { String($0 + 1) }, ^ , Foo.swift:76:21: error: expected expression in list of expressions .day: { String($0 + 1) }, ^ Foo.swift:76:21: error: … Read more

ambiguous reference to member ‘joined()’

You can readily tell that Swift was created by a C++ fanatic, by its fucking obtuse error messages. ⤹ Me             Swift compiler ⤵︎ In today’s episode of “what the fuck do you want, compiler?”, we tackle: foo.swift:186:39: error: ambiguous reference to member ‘joined()’ log.debug(“\(thingies.joined(separator: “, “))”) ^~~~~~~~ Swift.BidirectionalCollection:27:17: note: found this … Read more

Collection literals

Last week Ted Kremenek added support for container literals and subscripting to Clang. This was noted in various places, though mostly only as a statement and maybe an example of the new container literals. But I wanted to know how they’re implemented. The answer is pretty easy to find. The relevant code follows a similar … Read more