diff --git a/runtime/sema/check_unary_expression.go b/runtime/sema/check_unary_expression.go index 07b8998ee9..723179be7b 100644 --- a/runtime/sema/check_unary_expression.go +++ b/runtime/sema/check_unary_expression.go @@ -83,8 +83,8 @@ func (checker *Checker) VisitUnaryExpression(expression *ast.UnaryExpression) Ty ), }, ) - return InvalidType } + return InvalidType } innerType := referenceType.Type diff --git a/runtime/tests/checker/reference_test.go b/runtime/tests/checker/reference_test.go index b06d1caee2..3ddf699fd4 100644 --- a/runtime/tests/checker/reference_test.go +++ b/runtime/tests/checker/reference_test.go @@ -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) {