-
Notifications
You must be signed in to change notification settings - Fork 2
Description
In a situation where you import both FlyingSocks and Timeout
import FlyingSocks
import Timeoutand try to do something like
do {
for try await message in socket.messages.timeout(seconds: 30) {}
} catch where error is TimeoutError {}You get an error from the Swift compiler:
'TimeoutError' is ambiguous for type lookup in this context
Turns out FlyingSocks has its own (perhaps lagged-behind copy of) swift-timeout.
You might think you could resolve it by simply getting more specific by changing the catch to
catch where error is Timeout.TimeoutError {}But since there is a struct named Timeout inside the package Timeout, you get another error, since it's confusing the struct and the name of the package:
'TimeoutError' is not a member type of struct 'Timeout.Timeout'
The only way to get Swift to build without error is to explicitly import the TimeoutError struct:
import FlyingSocks
import Timeout
import struct Timeout.TimeoutErrorand change the line back to
catch where error is TimeoutError {}I think the only fix I can think of involves changing the name of the (unfortunately public) struct Timeout to something that isn't the name of the package, perhaps TimeoutState, or something similar?