Skip to content

[3.0] [Type checker] Don't overflow array bounds with #fileLiteral *ahem*. #4921

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

Conversation

DougGregor
Copy link
Member

Resolves rdar://problem/26586984.

(cherry picked from commit e5b9ad7)

Fixes rdar://problem/26586984.

(cherry picked from commit e5b9ad7)
@DougGregor DougGregor added this to the Swift 3.0 milestone Sep 22, 2016
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@rudkx please review

Copy link
Contributor

@rudkx rudkx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious about the diagnostic. Otherwise LGTM!

@@ -22,3 +22,5 @@ struct Path: _ExpressibleByFileReferenceLiteral {

let p1: Path = #fileLiteral(resourceName: "what.txt")
let p2 = #fileLiteral(resourceName: "what.txt") // expected-error{{could not infer type of file reference literal}} expected-note{{import Foundation to use 'URL' as the default file reference literal type}}

let text = #fileLiteral(resourceName: "TextFile.txt").relativeString! // expected-error{{type of expression is ambiguous without more context}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually ambiguous, or is this because there is no relativeString member in any of the things that #fileLiteral could be and we're emitting a misleading diagnostic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because there's no relativeString and we're emitting a misleading diagnostic. Actually, I think the default #fileLiteral type isn't even around; we get a different diagnostic about to having a relativeString member with the real SDK

@tkremenek tkremenek merged commit a0b6cdd into swiftlang:swift-3.0-branch Sep 22, 2016
@DougGregor DougGregor deleted the file-literal-crash-28061409-3_0 branch September 22, 2016 18:32
MaxDesiatov pushed a commit that referenced this pull request Sep 7, 2023
[pull] swiftwasm from main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants