Navigation Menu

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-5273] Bad diagnostic, very simple case of "type of expression is ambiguous without more context" #47848

Closed
NachoSoto opened this issue Jun 20, 2017 · 9 comments
Assignees
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

@NachoSoto
Copy link
Contributor

Previous ID SR-5273
Radar rdar://problem/33914443
Original Reporter @NachoSoto
Type Bug
Status Resolved
Resolution Done
Environment

Apple Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42)
Apple Swift version 4.0 (swiftlang-900.0.43 clang-900.0.22.8)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee @xedin
Priority Medium

md5: 2b9215092fd1b651487b476bcd9fef90

Issue Description:

func f(_ x: Int64) {}

f(Int("WHY IS THIS AMBIGUOUS DAMN IT")!)
error: repl.swift:3:39: error: type of expression is ambiguous without more context
f(Int("WHY IS THIS AMBIGUOUS DAMN IT")!)
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Removing the unwrap produces a correct result:

error: repl.swift:3:3: error: cannot convert value of type 'Int?' to expected argument type 'Int64'
f(Int("WHY IS THIS AMBIGUOUS DAMN IT"))
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@belkadan
Copy link
Contributor

cc @xedin

@slavapestov
Copy link
Member

@swift-ci create

@xedin
Copy link
Member

xedin commented Aug 17, 2017

@NachoSoto We currently produce following error (on master):

error: cannot convert value of type 'Int' to expected argument type 'Int64'
f(Int("WHY IS THIS AMBIGUOUS DAMN IT")!)
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
  Int64(                               )

@NachoSoto
Copy link
Contributor Author

Wait, you only tested unwrapping?? I know that produces the right diagnostic. See the description.

@NachoSoto
Copy link
Contributor Author

Did you test without unwrapping? This is still a bug in the latest beta.

@NachoSoto
Copy link
Contributor Author

Oh wait my bad, I remembered this wrong hehe.

Are there regression tests though?

@xedin
Copy link
Member

xedin commented Aug 17, 2017

@NachoSoto Yes, I've added a bunch new ones while working similar errors.

@NachoSoto
Copy link
Contributor Author

Awesome thank you! And sorry again for the confusion.

@xedin
Copy link
Member

xedin commented Aug 17, 2017

No problem! Thank you for reporting all of the errors, that really helps us to improve diagnostics.

@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