Is there a built-in size limit for a static initializer in Swift?

In a class, I have class variables simulated by a struct with static members like this:

internal class DEAccountCheck : AccountCheck {

  private struct Static {
    static var methodParameters: [String: (UInt16, [UInt16])] = [ // Modulus + weights indexed by method id.
      "00": (10, [2, 1, 2, 1, 2, 1, 2, 1, 2]),
      "01": (10, [3, 7, 1, 3, 7, 1, 3, 7, 1]),
      "02": (11, [2, 3, 4, 5, 6, 7, 8, 9, 2]),
      "03": (10, [2, 1, 2, 1, 2, 1, 2, 1, 2]),
      ...
    ]
  }

      

There are over 200 lines (entries) for the methodParameter dictionary. If I run my application, I get an EXC_BAD_INSTRUCTION exception when the debugger stops in the middle of my static initializer. I checked when this would happen and found that I could have up to 172 values. Another one: puff.

How can I successfully add all entries by normal code, the question arises if there is some known limit for static insiders.

+3


source to share


1 answer


It turned out that the exception came from a duplicate key that is not allowed. If the error messages in Swift are more user-friendly, the problem will be much easier. The ATM error messages in Swift are terrible.



+1


source







All Articles