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-2562] var in type-elided closure parameters causes crash #45167

Closed
swift-ci opened this issue Sep 5, 2016 · 3 comments
Closed

[SR-2562] var in type-elided closure parameters causes crash #45167

swift-ci opened this issue Sep 5, 2016 · 3 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software parser Area → compiler: The legacy C++ parser

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Sep 5, 2016

Previous ID SR-2562
Radar None
Original Reporter koenvanderdrift (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 8b6, Swift 3

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, Parser
Assignee @harlanhaskins
Priority Medium

md5: b14473829d27e08f50fd1fa7724f6baf

Issue Description:

(see also SO: http://stackoverflow.com/questions/39333617/use-map-to-change-struct-property-into-new-array/39334461#39334461)

Xcode playground crashes when using array.map in the following code. The crashlog is attached to this bug report.

struct Day {
   var day: String
}

var mondays: [Day] = []

for i in 0..<10 {
   let day = Day(day: "Monday")

   mondays.append(day)
}

print(mondays)

// create a new array where all days have the day property set to 'Tuesday'
let tuesdays = mondays.map { (var d) -> Day in
   d.day = "Tuesday"
   return d
}

print(tuesdays)
@belkadan
Copy link
Contributor

belkadan commented Sep 6, 2016

That var d syntax isn't legal anymore; we should be rejecting it at parse-time.

@harlanhaskins
Copy link
Collaborator

We don't reject it at parse time, because we add a fixit to move it inside the declaration in Sema. The issue here seems to be that the var validation check is guarded by decl->getTypeLoc().getTypeRepr(), which lets it slide through Sema until it trips a sanity check in SILGen.

@harlanhaskins
Copy link
Collaborator

Resolved with #4980

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

4 participants