Skip to content

Commit

Permalink
Remove redundant check
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdrag00nv2 committed Dec 8, 2023
1 parent 21c83f8 commit f2adc91
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
17 changes: 1 addition & 16 deletions runtime/sema/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,22 +304,7 @@ func CheckParameterizedTypeInstantiated(
typeArgs := t.TypeArguments()
typeParameters := t.TypeParameters()

typeArgumentCount := len(typeArgs)
typeParameterCount := len(typeParameters)

if typeArgumentCount != typeParameterCount {
report(
&InvalidTypeArgumentCountError{
TypeParameterCount: typeParameterCount,
TypeArgumentCount: typeArgumentCount,
Range: ast.NewRange(
memoryGauge,
pos.StartPosition(),
pos.EndPosition(memoryGauge),
),
},
)
}
// The check for the argument and parameter count already happens in the checker, so we skip that here.

// Ensure that each non-optional typeparameter is non-nil.
for index, typeParam := range typeParameters {
Expand Down
14 changes: 14 additions & 0 deletions runtime/tests/checker/typeargument_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,20 @@ func TestCheckParameterizedTypeIsInstantiated(t *testing.T) {
require.NoError(t, err)
})

t.Run("InclusiveRange<Int, UInt>", func(t *testing.T) {

t.Parallel()

err := test(t,
"let inclusiveRange: InclusiveRange<Int, UInt> = InclusiveRange(1, 10)",
)

errs := RequireCheckerErrors(t, err, 2)

assert.IsType(t, &sema.InvalidTypeArgumentCountError{}, errs[0])
assert.IsType(t, &sema.MissingTypeArgumentError{}, errs[1])
})

t.Run("InclusiveRange", func(t *testing.T) {

t.Parallel()
Expand Down

0 comments on commit f2adc91

Please sign in to comment.