-
Notifications
You must be signed in to change notification settings - Fork 141
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
[Compiler] Support compilation for conditional returns #3816
base: feature/compiler
Are you sure you want to change the base?
Conversation
5dcf14f
to
af6cffb
Compare
af6cffb
to
a4fb860
Compare
Cadence Benchstat comparisonThis branch with compared with the base branch onflow:feature/compiler commit e6f27ac Collapsed results for better readability
|
b42d50a
to
9926433
Compare
9926433
to
3cd94a0
Compare
desugaredDecl := d.desugarDeclaration(declaration.FunctionDeclaration).(*ast.FunctionDeclaration) | ||
if desugaredDecl == declaration.FunctionDeclaration { | ||
return declaration | ||
} | ||
|
||
return ast.NewSpecialFunctionDeclaration( | ||
d.memoryGauge, | ||
declaration.Kind, | ||
desugaredDecl, | ||
) |
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.
Unrelated fix: Initializers wasn't getting desugared (hence conditions in initializers wasn't working)
prevInheritedFuncsWithConditions := d.inheritedFuncsWithConditions | ||
prevEnclosingInterfaceType := d.enclosingInterfaceType | ||
|
||
d.inheritedFuncsWithConditions = d.inheritedFunctionsWithConditions(compositeType) | ||
d.enclosingInterfaceType = nil | ||
|
||
defer func() { | ||
d.inheritedFuncsWithConditions = prevInheritedFuncs | ||
d.inheritedFuncsWithConditions = prevInheritedFuncsWithConditions | ||
d.enclosingInterfaceType = prevEnclosingInterfaceType |
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.
Also an unrelated fix, but needed for the FT test. Composite types can be inside interfaces, in the form of events. And events have initializer functions, that should be desugar-ed/compiled. This path was uncovered by the desugar-ing of initializers (fix) above.
Closes #3772
Description
Design:
When a return statement is being compiled, if the enclosing function:
master
branchFiles changed
in the Github PR explorer