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-8760] misleading lvalue diagnostic #51268

Closed
swift-ci opened this issue Sep 15, 2018 · 3 comments
Closed

[SR-8760] misleading lvalue diagnostic #51268

swift-ci opened this issue Sep 15, 2018 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8760
Radar rdar://problem/44526579
Original Reporter apouche (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee apouche (JIRA)
Priority Medium

md5: 03f58f4bf50f1f6251cb763470a7faa8

Issue Description:

Code:

import UIKit

@discardableResult
public func =~ (size: inout CGSize, sizeTuple: (CGFloat, CGFloat)) -> CGSize {
  size = CGSize(width: sizeTuple.0, height: sizeTuple.1)
  return size
}

var t = 0
// var t:CGFloat = 0; is the proper fix
let v = UIView()
v.size =~ (t, 0)

This code leads to a misleading diagnostic:

Error🙁89, 16) left side of mutating operator isn't mutable: 'v' is a 'let' constant

Tweet reference.

@belkadan
Copy link
Contributor

cc @xedin

@xedin
Copy link
Member

xedin commented Sep 17, 2018

@swift-ci create

@hborla
Copy link
Member

hborla commented Jun 26, 2020

This is fixed in Swift 5.3. The above code now produces the following error messages:

error: value of type 'UIView' has no member 'size'
    v.size =~ (t, 0)
    ~ ^~~~
error: cannot convert value of type '(Int, CGFloat)' to expected argument type '(CGFloat, CGFloat)'
    v.size =~ (t, 0)
              ^

Could you please verify using Xcode 12 beta 1? Thank you!

@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. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants