Environment
I can reproduce this intermittently when compiling in debug mode in Xcode 13.3 beta, as well as on the nightly toolchain. Here is a Godbolt capturing this: Additional Detail from JIRA
| | |
|------------------|-----------------|
|Votes | 0 |
|Component/s | |
|Labels | Bug |
|Assignee | None |
|Priority | Medium |
md5: 797e776870dd42d821f41a7a36d192af
Issue Description:
When using two equal Substring s to lookup a value in a Dictionary, I found that sometimes the lookup will return nil for one of the keys. Here is a sample program that reproduces this (sometimes–I think it's reading garbage?):
let path = "./Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/DeviceTypes/iPhone Xʀ.simdevicetype"[...]
func parentDirectory<S: StringProtocol>(of path: S) -> S.SubSequence {
return path[..<path.lastIndex(of: "/")!]
}
let parent1 = "./Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/DeviceTypes"[...]
let parent2 = parentDirectory(of: path)
var dict = [Substring: Int]()
dict[parent1] = 1
print(parent1 == parent2, dict[parent1], dict[parent2])
Environment
I can reproduce this intermittently when compiling in debug mode in Xcode 13.3 beta, as well as on the nightly toolchain. Here is a Godbolt capturing this:Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 797e776870dd42d821f41a7a36d192afIssue Description:
When using two equal
Substring
s to lookup a value in aDictionary
, I found that sometimes the lookup will returnnil
for one of the keys. Here is a sample program that reproduces this (sometimes–I think it's reading garbage?):Here is the broken output: