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-153] Bad fix suggestion for changing value of capture list constants #42775

Closed
an0 mannequin opened this issue Dec 9, 2015 · 3 comments
Closed

[SR-153] Bad fix suggestion for changing value of capture list constants #42775

an0 mannequin opened this issue Dec 9, 2015 · 3 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@an0
Copy link
Mannequin

an0 mannequin commented Dec 9, 2015

Previous ID SR-153
Radar None
Original Reporter @an0
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee @gregomni
Priority Medium

md5: 65889bd9514c44c769cae337bd527d9a

Issue Description:

When trying to change the value of capture list constants compiler suggests "change 'let' to 'var' to make it mutable". But that's impossible for capture list.

Here is the code:

var a = 1

let f = {
    [a] in
    a = 3
    print(a)
}
@gregomni
Copy link
Collaborator

Fix for this in <https://github.com/apple/swift/pull/386\>.

@an0
Copy link
Mannequin Author

an0 mannequin commented Jul 8, 2016

This bad fix message is still here in Swift 3 and the fix action changes `[a]` to `[var]`.

@gregomni
Copy link
Collaborator

gregomni commented Jul 9, 2018

This got fixed somewhere along the way. Error now is:

cannot assign to value: 'a' is an immutable capture

and there is no fix suggestion.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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.
Projects
None yet
Development

No branches or pull requests

1 participant