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-11964] bad diagnostic for mismatched numeric types #54389
Comments
Can you try this on a recent development snapshot from swift.org? The diagnostics might have been improved. |
@theblixguy Actually what I get on the most recent snapshot (2019-12-16 (a)) is "Cannot assign to property: 'self' is immutable", which is insane. |
@swift-ci create |
@xedin says the diagnostic is referring to |
This is a good starter bug! Here's a reproducer: import AppKit
let view = NSView()
_ = view.frame.width * Double(0.8) which currently produces: error: value of type '(NSRect) -> NSRect' (aka '(CGRect) -> CGRect') has no member 'width'
_ = view.frame.width * Double(0.8)
~~~~~~~~~~ ^~~~~ |
A simpler case without AppKit: struct Rect {
let width: Int
let height: Int
}
class Frame {
func rect(width: Int, height: Int) -> Rect {
Rect(width: width, height: height)
}
let rect: Rect
}
func foo(frame: Frame) {
frame.rect.width + 10.0
} error: value of type '(Int, Int) -> Rect' has no member 'width'
frame.rect.width + 10.0
~~~~~~~~~~ ^~~~~ |
Comment by Vuk (JIRA) Is this still available? I would like to give it a shot. |
vukrado (JIRA User) yes, this is still available! Please feel free to ask questions if you need help. |
Comment by Vuk (JIRA) Sounds good thank you @hborla! Can I go ahead and assign myself to the issue? |
vukrado (JIRA User) yes, please assign to yourself! |
Has been fixed by #29795 vukrado (JIRA User) Thank you for the patch! |
Environment
Xcode 11.3
Additional Detail from JIRA
md5: 679d6d75f86aaa3d7603e69fb7170afb
is duplicated by:
Issue Description:
The actual error here is obviously that `d` is a Double but `self.view.frame.size` is a CGFloat. However, the error message reads:
That is quite a fascinating diagnostic. Notice that this is not saying that CGRect has no `size`. It is talking about a function that takes a CGRect and returns a CGRect. I cannot imagine what function it has in mind!
The text was updated successfully, but these errors were encountered: