Uploaded image for project: 'Swift'
  1. Swift
  2. SR-9618

An initializer that delegates to a failable initializer has no way to check if the inner call failed.

    XMLWordPrintable

    Details

      Description

      As I understand it, there are two ways for an initializer that delegates to a failable initializer to react to the delegated initializer failing.

      1. If the delegating initializer is nonfailable, then it must call the other initializer with a trailing "!" to cause a crash if it fails.
      2. If the delegating initializer can fail, it can call the other initializer without any suffix and the system will make sure the outer initializer will pass on the inner's fail-ness if that occurs.

      There doesn't seem to be a way for the outer initializer to test that the inner one failed and carry out some other policy, like throwing an error.  I don't know if there's any other solutions beside throwing an error.  (You could re-evaluate another value with another initializer call, but we may want to limit the number of delegated initializer calls to one.)

      There's more information at a thread I created before this.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              CTMacUser Daryle Walker
            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: