This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
fix: only wrap single struct param in a tuple #368
Merged
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.
Motivation
This is a follow up for #363 which introduced invalid encoding if the function has not a single struct parameter.
The reason why this is a bit error prone is due the token flattening that takes place during encoding of the input params where the outmost
Tuple
layer gets removed. This is intentionally because all function arguments are passed to themethod_hash
function as tuple which adds theTuple
layer in the first place.However, if the function input is a single struct, prior to #363 the param would be
((input))
which is not a rust tuple butinput
itself is, soflatten_tokens
would later strip away the outmostTuple
layer of the input itself, instead of the additionalTuple
layer that would have been added if((input))
where a rust tuple.So in #363 I attempted to fix this by enforcing tuple encoding
((input))
if the param is a tuple, however I did not understand that this was the entire edge case so #363 results in invalid encoding for multiple params (which enforce tuple encoding)Solution
Since the edge case is:
we can add this condition in to the match arm