Possible compiler issue with typed Error

I expose the following in a local package in a Xcode project:

extension TaskSchedule {
    public enum ValidationError: Error {
        case endDateBeforeStartDate
        case endDateInPast
    }
    
    public func validate(now: Date = .now) throws(ValidationError) {
        // Validate endDate if present
        if let endDate = endDate {
            // Check: endDate > startDate
            guard endDate > startDate else {
                throw ValidationError.endDateBeforeStartDate
            }
            
            // Check: endDate > now
            guard endDate > now else {
                throw ValidationError.endDateInPast
            }
        }
    }
}

Then in the project I try to do the following:

import Models

@State private var validationError: TaskSchedule.ValidationError?

//....

struct MyView: View {
    var body: some View {
         VStack {
         // ...
         }
         .onChange(of: taskSchedule, initial: true) { _, newValue in
              do {
                  try newValue.validate()
                  validationError = nil
              } catch {
                  validationError = error
              }
         }
    }
}

and I get the following error when I do the validationError = error:

Cannot assign value of type 'any Error' to type 'TaskSchedule.ValidationError'

Shouldn't the type be available in this context? Am I missing something or is it a bug in the compiler?

I'm on Xcode 16.4, Swift 6.1.2

You don't actually show the relevant code, but I presume that validate() is declared as throws(TaskSchedule.ValidationError).

This is similar to Typed throws not honored for call to generic closure in closure · Issue #82100 · swiftlang/swift · GitHub, but I'm not sure it's identical.

The declaration of the validate function is at the top of the post. Thanks for the link, it's probably related