Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-12703] Another Occurrence of the Misleading Error Message "subscript 'subscript(_:)' requires the types 'String.Index' and 'Int' be equivalent" #55147

Open
marcomasser opened this issue Apr 29, 2020 · 1 comment
Labels
compiler The Swift compiler in itself improvement

Comments

@marcomasser
Copy link

Previous ID SR-12703
Radar rdar://problem/62895068
Original Reporter @marcomasser
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement
Assignee None
Priority Medium

md5: 735fafb0b9ba9b382f64db0d1e7848a9

relates to:

  • SR-10932 Incorrect Error Description For Substrings
  • SR-11702 Misleading Error Message "Subscript 'subscript(_: )' requires the types 'String.Index' and 'Int' be equivalent"

Issue Description:

Two issues were fixed that resulted in the same misleading error message: SR-11702 and SR-10932. But this code still triggers it:

var lines: [String] = []
let line = "this is a line"
lines.append(line[line.startIndex...])

This is the output:

bug.swift:3:18: error: subscript 'subscript(_:)' requires the types 'String.Index' and 'Int' be equivalent
lines.append(line[line.startIndex...])
                 ^
Swift.String:5:12: note: where 'R.Bound' = 'String.Index'
    public subscript<R>(bounds: R) -> String where R : RangeExpression, R.Bound == Int { get }
           ^
@beccadax
Copy link
Contributor

beccadax commented May 5, 2020

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself improvement
Projects
None yet
Development

No branches or pull requests

2 participants