WIP: replace capnpronto
with serde
+ bincode
#2800
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why is this PR marked as WIP?
Well, there's a problem I want to ask about.
Right now we can correctly serialize and deserialize all internal objects, except the fact that
TypeVar
's ids are not regenerated. This is needed to uniquely identify type vars and to make sure that there are no conflicts.Old module had this code:
gleam/compiler-core/src/metadata/module_decoder.rs
Lines 140 to 155 in efc519c
The first proposed solution by @HarryET #1912 had this logic: https://github.com/HarryET/gleam/blob/b46f227ac18f9bbe2e36de2a7c9b73505ba74282/compiler-core/src/metadata.rs#L22-L42
But, the code above is incomplete (it does not have
types_value_constructors
,values
andaccessors
processing). It is also not very clean and will require constant modification.The problem is that
serde
does not allow simple stateful deserialization. It hasDeserializeSeed
API which is not an easy API to use and to connect withbincode
.The second problem is that
bincode@1.0
will soon be replaced withbincode@2.0
which will not havedeserialize_from_seed
API. So, I don't think that it is worth doing that as well.I've also tried https://github.com/Marwes/serde_state to work with the global state, but it is unmaintained.
So, what should we do? :)
Tests are failing because of that.
Most of the credit for this change goes to @HarryET
Thank you!
Closes #1599