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

Sequence.first(where:) shouldn't use throw internally for success

    XMLWordPrintable

    Details

      Description

      The implementation for the new `Sequence.first(where:)` function in Swift 3 internally uses a `throw _StopIteratop.stop` to exit a `forEach` loop on success.

      While merits of this approach can be discussed, the immediate impact on developers is that Xcode breaks every time an item is found when using the Break on Swift Errors debugger breakpoint.

      Since Xcode internally breaks on `swift_willThrow()` when you ask it to break on Swift Errors, the standard library should refrain from internally using `throw` for regular control flow until tooling can support filtering of false positives.

      One way or the other, the current state of things should change. One solution would be that swiftc does not emit the call to `swift_willThrow()` in certain known internal cases.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              fpillet Florent Pillet
            • Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated: