Skip to content

Commit 664d9d3

Browse files
knoctewebwarrior-ws
andcommitted
tests/RedundantNewKeyword: new 'use' testcase
Given that using the 'use' keyword on a non-IDisposable type would be flagged by the F# compiler as an (FS0193) error, we should assume that the type implements IDisposable when this keyword is present (because it's logical to assume that you run FSharpLint as an extra layer of correctness on top of compilation itself). Co-authored-by: webwarrior-ws <[email protected]>
1 parent 6e434a6 commit 664d9d3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/FSharpLint.Core.Tests/Rules/Conventions/RedundantNewKeyword.fs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,15 @@ module Program
7474
"""
7575

7676
Assert.IsTrue this.ErrorsExist
77+
78+
[<Test>]
79+
member this.``unresolved type with 'use' should not give rule violations``() =
80+
this.Parse """
81+
module Program
82+
let SomeFunc() =
83+
use foo = new UnresolvedType()
84+
foo.Foo
85+
"""
86+
87+
Assert.IsFalse this.ErrorsExist
88+

0 commit comments

Comments
 (0)