Skip to content

Commit

Permalink
Fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
SupunS committed May 9, 2024
1 parent 63abc0f commit e0d5536
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 0 additions & 2 deletions runtime/sema/check_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,6 @@ func (checker *Checker) visitMemberExpressionAssignment(
reportAssignmentToConstant()
}

memberType = member.TypeAnnotation.Type

if memberType.IsResourceType() {
// if the member is a resource, check that it is not captured in a function,
// based off the activation depth of the root of the access chain, i.e. `a` in `a.b.c`
Expand Down
14 changes: 10 additions & 4 deletions runtime/tests/checker/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,9 @@ func TestCheckAccessImportGlobalValueVariableDeclarationWithSecondValue(t *testi
},
)

errs := RequireCheckerErrors(t, err, 7)
errs := RequireCheckerErrors(t, err, 9)

// For `x`

require.IsType(t, &sema.InvalidAccessError{}, errs[0])
assert.Equal(t,
Expand All @@ -1870,15 +1872,19 @@ func TestCheckAccessImportGlobalValueVariableDeclarationWithSecondValue(t *testi

require.IsType(t, &sema.ResourceCapturingError{}, errs[4])

// For `y`

require.IsType(t, &sema.ResourceCapturingError{}, errs[5])

require.IsType(t, &sema.AssignmentToConstantError{}, errs[6])
require.IsType(t, &sema.ResourceCapturingError{}, errs[6])

require.IsType(t, &sema.AssignmentToConstantError{}, errs[7])
assert.Equal(t,
"y",
errs[6].(*sema.AssignmentToConstantError).Name,
errs[7].(*sema.AssignmentToConstantError).Name,
)

require.IsType(t, &sema.ResourceCapturingError{}, errs[6])
require.IsType(t, &sema.ResourceCapturingError{}, errs[8])
}

func TestCheckContractNestedDeclarationPrivateAccess(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions runtime/tests/checker/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10113,9 +10113,6 @@ func TestCheckInvalidNestedResourceCapture(t *testing.T) {
destroy y
}
}
destroy() {
destroy self.x
}
}
`)
errs := RequireCheckerErrors(t, err, 1)
Expand Down

0 comments on commit e0d5536

Please sign in to comment.