Skip to content

RFC / DO NOT MERGE – Remove TVO_CanBindToInOut, add TVO_IsGenericTypeParam #15574

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

Closed

Conversation

davezarzycki
Copy link
Contributor

As a part of the ongoing "war on InOutType", I've made an attempt at cleaning up the TypeVariable options. After this patch series, TVO_CanBindToInOut is gone and the validation test suite still passes on my Linux box. Feedback would be appreciated. Please note that I did need to XFAIL one of the "compiler crasher" tests, but this seemed acceptable.

We want InOutType to go away and the majority of callers pass
TVO_CanBindToInOut, therefore change the default to be TVO_CanBindToInOut and
allow the weird cases that need reconciling to use TVO_CannotBindToInOut.
If InOutType doesn't exist, then "cannot bind" doesn't make sense.
@davezarzycki
Copy link
Contributor Author

@swift-ci please test

@CodaFi
Copy link
Contributor

CodaFi commented Mar 28, 2018

It’s an interesting idea, but isn’t the inverted polarity spreading the flag even further implicitly? An audit of this flag should pretty much only need to conserve it around closures for inout inference - everywhere else is suspect (you found one place in the opening process that can be flipped already).

@davezarzycki
Copy link
Contributor Author

Are you saying that the use of TVO_CanBindToInOut is not always justified, and that removing it as much as possible is preferable to making it be the default?

@CodaFi
Copy link
Contributor

CodaFi commented Mar 28, 2018

It's pretty much never needed. @slavapestov applied it to all the type variables at the time out of an abundance of caution.

@davezarzycki
Copy link
Contributor Author

Got it. Thanks!

@davezarzycki davezarzycki deleted the remove_TVO_CanBindToInOut branch March 28, 2018 16:06
@rudkx
Copy link
Contributor

rudkx commented Mar 28, 2018

FWIW, I looked at removing some of these recently, specifically in the pattern binding code that you've been working on, and the problem is that we then fail to get a solution in the solver for certain bogus expressions and then go on to produce a worse diagnostic.

I think if we eliminate the inout-to-pointer conversions for operators (as seen here), we can make & part of the argument grammar, emit a parse error in other places (or re-claim this as a unary operator), and then eliminate more uses of the InOut type variable flag.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 9447f21

@davezarzycki
Copy link
Contributor Author

If the unary &, a.k.a. InOutExpr syntax is to become a parser problem, then will we need to ban it in IfExpr? For example b ? &x : &y:

See test/expr/expressions.swift, line 819, and friends.

@slavapestov
Copy link
Contributor

@davezarzycki It's an error for InOutExpr to appear in an IfExpr like that anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants