-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[libSyntax] Make the ByteTree format forwards-compatible #18889
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
Conversation
@swift-ci Please smoke test |
Incompatibility happens if we:
IIUC, This PR only improves "Increase number of fields" case. I'm not sure it's worth to do it. |
Yes, the only change that is made compatible by this patch is to add new fields, but I think it comes at a pretty low cost and we should be able to get pretty much the same compatibility that we used to have from JSON from it:
The general idea is that I just want us to be able to do minor modifications without breaking serialisation compatibility and not regretting later that we didn't implement this earlier. If we need to make an incompatible change, we can still increase the version number. A few examples that come to my mind right now:
|
90a815e
to
efdf506
Compare
@swift-ci Please smoke test |
efdf506
to
34a89d4
Compare
@swift-ci Please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the example use case in your mind!
The patch itself looks good.
return 2; | ||
// FIXME: We know this is never set in production builds. Should we | ||
// disable this code altogether in that case | ||
// (e.g. if assertions are not enabled?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if we could implement independent unit tests to test serialization/deserialization.
@swift-ci Please smoke test and merge |
Adjust the ByteTree format so that the server can add new versions to the tree it serialises while the client is still able to deserialise it.
To test the forwards compatibility, I added a flag that can be passed to the serialisation of the syntax tree as a ByteTree that will add additional garbage fields that the client should ignore. While this is not exactly beautiful, it is way easier to maintain than generating an entire class structure, constructing an object tree and adding the same class layout on the Swift side just to diff the output.