Skip to content

Commit

Permalink
Merge pull request #1249 from onflow/bastian/fix-regression-in-restri…
Browse files Browse the repository at this point in the history
…cted-type-conversion
  • Loading branch information
turbolent authored Nov 17, 2021
2 parents 91c67f5 + 53ddeff commit 81c63bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions runtime/sema/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,10 @@ func (checker *Checker) convertRestrictedType(t *ast.RestrictedType) Type {
Range: ast.NewRangeFromPositioned(restriction),
})
}

// NOTE: ignore this invalid type
// and do not add it to the restrictions result
continue
}

restrictions = append(restrictions, restrictionInterfaceType)
Expand Down
14 changes: 14 additions & 0 deletions runtime/tests/checker/restriction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1124,3 +1124,17 @@ func TestCheckRestrictedConformance(t *testing.T) {

require.NoError(t, err)
}

func TestCheckInvalidRestriction(t *testing.T) {

t.Parallel()

_, err := ParseAndCheck(t, `
let x: {h} = nil
`)

errs := ExpectCheckerErrors(t, err, 2)

require.IsType(t, &sema.NotDeclaredError{}, errs[0])
require.IsType(t, &sema.AmbiguousRestrictedTypeError{}, errs[1])
}

0 comments on commit 81c63bf

Please sign in to comment.