Skip to content

Missing public initializers for LongTermScheduler and ShortTermScheduler #2

@jeppe-dg

Description

@jeppe-dg

I am a complete beginner to coding, so take everything below with a grain of salt! I experience the following error, diagnosed by LLMs. If this is indeed an error, I would appreciate a fix - otherwise I apologise.

Problem

The LongTermScheduler and ShortTermScheduler structs are declared as public but lack explicit public initializers, making them unusable from external modules.

Error Message

'LongTermScheduler' initializer is inaccessible due to 'internal' protection level

Root Cause

In Swift, when a public struct has no stored properties and no custom initializer, the compiler generates a default init() with internal access level, not public.

Current Code

public struct LongTermScheduler: Scheduler {
  public func schedule(...) -> CardReview {
    // implementation
  }
}

Solution

Add explicit public initializers:

public struct LongTermScheduler: Scheduler {
  public init() { } // Add this line
  
  public func schedule(...) -> CardReview {
    // existing implementation
  }
}

public struct ShortTermScheduler: Scheduler {
  public init() { } // Add this line
  
  public func schedule(...) -> CardReview {
    // existing implementation
  }
}

Impact

This prevents external users from creating instances of the schedulers, effectively making the library unusable as intended.

Workaround

Currently, users must implement their own Scheduler conforming types instead of using the provided implementations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions