-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Improve the error message for passing (any P)?
to (some P)?
#61733
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
Comments
@hborla, I would love to work on it. But I'm completely new to this repo (and open source contribution in general). It would be very kind of you tell me how do I go about it |
@IceCurrent welcome to the Swift project! I'm happy you're interested in working on this issue 🙂 Are you set up to build the Swift compiler yet? There are a few getting started guides: The first one contains instructions for checkout and build the Swift compiler, and the second has an FAQ for new contributors. Let me know once you've gotten set up and I can provide some guidance on investigating this issue! |
@IceCurrent Hey! Are you still working on this? I can take this fix up if you're no longer interested. |
No worries at all! @enathang please let me know if you have questions or need guidance! |
Thanks @hborla! Currently waiting on a new external hard drive because my computer ran out of space trying to build the project. In the mean time, I looked over the documentation (specifically the overview of constraint system) and this commit. If you have any additional info on the constraint system feel free to pass along, it seems cool! Will update once I have the project built and start poking through files. |
@hborla Is there any info on reducing the size requirement of Swift/xcode/swift toolchain? I'm wondering if I'd like to only work on a part of the toolchain (ie type constraint) I could swap out other parts of the toolchain with compiled versions to reduce space. I have a 2017 128GB macbook air. I've stripped out every non-swift related file on my computer to free space and I'm still running into disk space issues. Your thoughts would be much appreciated! |
Managed to get everything working through a flash drive. I've done a bit of testing to determine the behavior of the compiler currently: Passing I'll keep looking into this. |
@enathang Are you still working on this? If not, I'd like to give it a try. |
Go for it! I worked on it for a while but never quite figured it out. |
Hi @LucianoPAlmeida @hborla @AnthonyLatsis, I've given this a try but could use some pointers if someone has the time. The crux of the issue I'm running into is convincing the type checker to choose the We can see this in the constraint debugging output:
Strategies I've tried so far:
Some general questions I have, again if there is time:
|
@hborla or @xedin may be the best advice here, but from what I could get from looking at it is that we are recording a missing conformance from an existential Also @hborla, it looks like the second case still fails https://godbolt.org/z/bzeP1EKM5. Is that a bug? |
This issue seems really interesting to grind! Let me try and find a solution to it! |
You definitely can, but I think this issue has an assignee already. So we always recommend to ask the current assignee (or person who commented that is working on it) first. See How do I pick something to work on for more details. |
I'll still be working on it, but I have other things on my plate as well, so if you find a solution first, that's fine too 🙂 |
Cool! |
Small update for those interested: Perhaps this was clear to others, but it wasn't to me; the reason we are seeing a This means unless we open the existential, we will always have to apply the I'm trying now to conditionally open the existential only when applying fixes, and after applying the |
I've created a draft PR here: #63667. It by no means solves the issue, but I've written a comment explaining where I'm struggling. I will take another stab at it sometime later when I have the time, but any pointers would be appreciated @LucianoPAlmeida @hborla @AnthonyLatsis 🙂 Also @Rajveer100 feel free to chime in if you have any ideas. |
Well, I am grinding as of now! |
I think changes in these files could affect the error right?
Particularly, this function: |
In my opinion, you should be looking farther from the the diagnostic emission call sites, around the Random collection of resources I used to get some understanding of existential types: https://developer.apple.com/videos/play/wwdc2016/416/ |
Thanks! @NuriAmari |
If you try to pass a value of type
(any P)?
to an argument of type(some P)?
, the compiler tells you thatany P
cannot conform toP
, which is confusing and not actionable. With SE-0375, existential opening/unboxing is supported with optionals, but only if the argument is not an optional because it's possible that the(any P)?
isnil
(and thus does not have a dynamic type to bind tosome P
). With SE-0375, the fix is to unwrap the optional or provide a default value. So, the error message should tell you that!The constraint system currently applies the
MissingConformance
fix when solving for thetakesOptionalP(value)
expression. Instead, it should identify that the wrapped type of the argument matches the parameter type, and apply theForceOptional
fix.The text was updated successfully, but these errors were encountered: