Open piux2 opened 1 week ago
Attention: Patch coverage is 27.58621%
with 42 lines
in your changes missing coverage. Please review.
Project coverage is 54.61%. Comparing base (
e7e47d2
) to head (429ddb6
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This is the last part of the solution for issue #1141. The 1 of 3 of the solution can be found in PR #1143. The 2 of 3 of the solution can be found in PR #1246
It decomposes function calls that return multiple values in the preprocess.
Here is the problem to solve:
u1, n2 = x()
How do we ensure that the returned multiple values from a function call adhere to named and unnamed type assignment specifications? Additionally, we want to solve this problem during preprocessing instead of at runtime to minimize the impact on runtime performance.
The main ideas:
Here are the example code and the explanation
Here is the simplified recursive tree of the transformation in the preprocess
Here are the major steps involved in this decomposition during preprocessing:
Create hidden temporary name expressions .tmp1, .tmp2. In Go, a leading dot is not valid in variable names, ensuring that users cannot create names that clash with these hidden variables.
Create two statements in the block: one for defining and one for assigning.
Preprocess each newly created statements
Replace the original statement with the two newly created statements.
Here are two additional changes to facilitate above.
Update the FuncValue's body in
updates := pn.PrepareNewValues(pv)
since its source Body has been changed during preprocessing.Replace all
for index := range Body
withfor i:=0; i < len(Body); i++
in transcribe.go since the body length might change due to the decomposition.Contributors' checklist...
- [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [x] No breaking changes were made - [x] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).