NSString.range(of:options:range:locale) incompatibility

I've noticed this current difference in behaviour.

Darwin:

$ swift
Welcome to Apple Swift version 4.0-dev (LLVM 2dedb62a0b, Clang b9d76a314c,
Swift 6b4756bd93). Type :help for assistance.
  1> import Foundation
  2> "abc".range(of: "a")!.lowerBound..<"abc".range(of: "a")!.upperBound
$R0: Range<String.Index> = {
  lowerBound = {
    _compoundOffset = 0
    _cache = utf16
  }
  upperBound = {
    _compoundOffset = 4
    _cache = utf16
  }
}

Linux:

$ swift
Welcome to Swift version 4.0-dev (LLVM 2dedb62a0b, Clang b9d76a314c, Swift
6b4756bd93). Type :help for assistance.
  1> import Foundation
  2> "abc".range(of: "a")!.lowerBound..<"abc".range(of: "a")!.upperBound
$R0: CountableRange<String.Index> = {
  lowerBound = {
    _compoundOffset = 0
    _cache = utf16
  }
  upperBound = {
    _compoundOffset = 4
    _cache = utf16
  }
}

I think this might be because some changes made in the overlay
(NSStringAPI.swift) haven't been ported across to swift-corelibs-foundation:

https://github.com/apple/swift/commit/5f1c3f702189f8197e297479d464dc454330be80

Is my suspicion right, and is there any work in progress to bring this into
sync before Swift 4?

···

--
Ian Partridge

Hi Ian,

I don’t think Max has put up that PR against the swift-corelibs-foundation implementation, but we should.

- Tony

···

On Aug 9, 2017, at 9:04 AM, Ian Partridge via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:

I've noticed this current difference in behaviour.

Darwin:

$ swift
Welcome to Apple Swift version 4.0-dev (LLVM 2dedb62a0b, Clang b9d76a314c, Swift 6b4756bd93). Type :help for assistance.
  1> import Foundation
  2> "abc".range(of: "a")!.lowerBound..<"abc".range(of: "a")!.upperBound
$R0: Range<String.Index> = {
  lowerBound = {
    _compoundOffset = 0
    _cache = utf16
  }
  upperBound = {
    _compoundOffset = 4
    _cache = utf16
  }
}

Linux:

$ swift
Welcome to Swift version 4.0-dev (LLVM 2dedb62a0b, Clang b9d76a314c, Swift 6b4756bd93). Type :help for assistance.
  1> import Foundation
  2> "abc".range(of: "a")!.lowerBound..<"abc".range(of: "a")!.upperBound
$R0: CountableRange<String.Index> = {
  lowerBound = {
    _compoundOffset = 0
    _cache = utf16
  }
  upperBound = {
    _compoundOffset = 4
    _cache = utf16
  }
}

I think this might be because some changes made in the overlay (NSStringAPI.swift) haven't been ported across to swift-corelibs-foundation:

https://github.com/apple/swift/commit/5f1c3f702189f8197e297479d464dc454330be80

Is my suspicion right, and is there any work in progress to bring this into sync before Swift 4?

--
Ian Partridge
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

Terms of Service

Privacy Policy

Cookie Policy