Skip to content

Commit

Permalink
Merge pull request #3216 from onflow/bastian/3214-fix-non-reference-t…
Browse files Browse the repository at this point in the history
…ype-dereference
  • Loading branch information
turbolent authored Apr 3, 2024
2 parents 2cb99c1 + 8f30ea1 commit 4721725
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion runtime/sema/check_unary_expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ func (checker *Checker) VisitUnaryExpression(expression *ast.UnaryExpression) Ty
),
},
)
return InvalidType
}
return InvalidType
}

innerType := referenceType.Type
Expand Down
21 changes: 21 additions & 0 deletions runtime/tests/checker/reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3546,6 +3546,27 @@ func TestCheckDereference(t *testing.T) {
`,
)
})

runInvalidTestCase(
t,
"non-reference",
`
fun test(foo: Int): AnyStruct {
return *foo
}
`,
)

t.Run("invalid type", func(t *testing.T) {
t.Parallel()

_, err := ParseAndCheck(t, `
let x = *y
`)

errs := RequireCheckerErrors(t, err, 1)
assert.IsType(t, &sema.NotDeclaredError{}, errs[0])
})
}

func TestCheckReferenceRequiredTypeAnnotation(t *testing.T) {
Expand Down

0 comments on commit 4721725

Please sign in to comment.