-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When a function has named results and uses empty return, the named result would correctly be renamed and hoisted into the frame struct. In that scenario, using an explicit return (such as "return myvalue") works, because the renaming pass goes over the expression in the return statement and replaces the named result with a selector into the frame struct. However, when using an empty return (just "return"), the named result is not in the AST, and the renaming pass would not see it. This patch add and final pass to the renaming procedure to change empty returns in functions with named results into explicit returns using selectors into the frame struct. For example: func example() (out int) { out = 42 return } gets rewritten into: func example() (_fn0 int) { var _f0 *struct { IP int X0 int } _f0.X0 = 42 return _f0.X0 } (other transformations omitted for this example)
- Loading branch information
Showing
5 changed files
with
109 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters