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-10291] Some of the error messages might require trimming #52691

Open
xedin opened this issue Apr 3, 2019 · 6 comments
Open

[SR-10291] Some of the error messages might require trimming #52691

xedin opened this issue Apr 3, 2019 · 6 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers

Comments

@xedin
Copy link
Contributor

xedin commented Apr 3, 2019

Previous ID SR-10291
Radar rdar://problem/49393677
Original Reporter @xedin
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, StarterBug
Assignee None
Priority Medium

md5: 59ddf07a63039e0c74cd437ae791689d

Issue Description:

Consider following example:

func foo(_: UnsafePointer<Int8>?) {}
foo((1, 2, 3))

This results in:

cannot convert value of type '(Int, Int, Int)' to expected argument type 'UnsafePointer<Int8>?'

So the more elements to the tuple we add, the bigger the message is going to get.

I think it makes sense to trim contents of the tuple which has same types to something like `(Int8, ..., Int8)` to make sure that it doesn't grow too long.

@belkadan
Copy link
Contributor

belkadan commented Apr 4, 2019

I'm concerned about doing this if both values are tuples and there might be a mismatch:

cannot convert value of '(Int, Float, Double, Float, Int)' to expected argument type '(Int, Float, UInt, Float, Int)'

This might not be at the top-level either; the two types might both be pointers to such tuples. Clang has a complicated Type diffing system to try to see when this is the case, but I don't know how it handles implicit conversions.

@xedin
Copy link
Contributor Author

xedin commented Apr 4, 2019

That's a fair point! I think we should at least handle easy cases here like - if there is a single conflicting element - mention its type and position in custom error message, otherwise try to see if types could be folded. For the nested tuples we could also probably mention them separately and note what position they were in.

@belkadan
Copy link
Contributor

belkadan commented Apr 4, 2019

It's also the sort of thing we could at least have a frontend flag to turn off, if it turns out the compiler is hiding information that someone needs.

@xedin
Copy link
Contributor Author

xedin commented Apr 4, 2019

Sounds good!

@swift-ci
Copy link
Contributor

swift-ci commented Aug 2, 2021

Comment by Rajagopalan Gangadharan (JIRA)

@xedin @belkadan This seems to be an interesting task. Could I work on this? if yes could you please give some pointers that might be useful. Thank you!

@swift-ci
Copy link
Contributor

swift-ci commented Aug 2, 2021

Comment by Rajagopalan Gangadharan (JIRA)

If I understand this right, we should be adding a flag say truncate-type or something. If its turned on Then similar types to be grouped For eg (Int,Int,Int,Int,Float,Float,Float,Float) could be written as

(Int...,Float..) something like this?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants