Skip to content

Commit

Permalink
respond to review
Browse files Browse the repository at this point in the history
  • Loading branch information
dsainati1 committed Oct 17, 2023
1 parent 8363693 commit 5defa03
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
31 changes: 17 additions & 14 deletions runtime/sema/check_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,23 @@ func (checker *Checker) checkFunction(
functionActivation.InitializationInfo = initializationInfo

if functionBlock != nil {
oldMappedAccess := checker.entitlementMappingInScope
if mappedAccess, isMappedAccess := access.(*EntitlementMapAccess); isMappedAccess {
checker.entitlementMappingInScope = mappedAccess.Type
}

checker.InNewPurityScope(functionType.Purity == FunctionPurityView, func() {
checker.visitFunctionBlock(
functionBlock,
functionType.ReturnTypeAnnotation,
checkResourceLoss,
)
})

checker.entitlementMappingInScope = oldMappedAccess
func() {
oldMappedAccess := checker.entitlementMappingInScope
if mappedAccess, isMappedAccess := access.(*EntitlementMapAccess); isMappedAccess {
checker.entitlementMappingInScope = mappedAccess.Type
} else {
checker.entitlementMappingInScope = nil
}
defer func() { checker.entitlementMappingInScope = oldMappedAccess }()

checker.InNewPurityScope(functionType.Purity == FunctionPurityView, func() {
checker.visitFunctionBlock(
functionBlock,
functionType.ReturnTypeAnnotation,
checkResourceLoss,
)
})
}()

if mustExit {
returnType := functionType.ReturnTypeAnnotation.Type
Expand Down
2 changes: 1 addition & 1 deletion runtime/sema/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,7 @@ func (checker *Checker) functionType(
} else {
checker.entitlementMappingInScope = nil
}
defer func() { checker.entitlementMappingInScope = oldMappedAccess }()

convertedParameters := checker.parameters(parameterList)

Expand All @@ -1271,7 +1272,6 @@ func (checker *Checker) functionType(
convertedReturnTypeAnnotation =
checker.ConvertTypeAnnotation(returnTypeAnnotation)
}
checker.entitlementMappingInScope = oldMappedAccess

return &FunctionType{
Purity: PurityFromAnnotation(purity),
Expand Down

0 comments on commit 5defa03

Please sign in to comment.