Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More tests
Browse files Browse the repository at this point in the history
edgarfgp committed Sep 30, 2023
1 parent aaea560 commit c0b433c
Showing 2 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

type MyIndexerClass() =
member x.Item
member x.Indexer1
with get (index: int): string = ""
and set (index: int) (value: float) = ()
and set (index: int) (value: float) = ()

member x.Indexer2
with get (index) = 1
and set (index) (value: float) = ()

member x.Indexer3
with get index = 1
member x.Indexer3
with set index (value: float) = ()

member x.Indexer4
with get (index: int, index2: int): float = 0.0
and set (index1: int, index2: int) (value: string) = ()

member x.Indexer5
with get (index, index2) = 0.0
and set (index1, index2) value = ()

type GenericIndexer<'indexerArgs,'indexerOutput,'indexerInput>() =
let mutable m_lastArgs = Unchecked.defaultof<'indexerArgs>
let mutable m_lastInput = Unchecked.defaultof<'indexerInput>

member this.LastArgs = m_lastArgs
member this.LastInput = m_lastInput

member this.Item with get (args : 'indexerArgs) =
m_lastArgs <- args;
Unchecked.defaultof<'indexerOutput>
and set (args : 'indexerArgs) (input : 'indexerInput) =
m_lastArgs <- args
m_lastInput <- input
Original file line number Diff line number Diff line change
@@ -40,7 +40,14 @@ module MemberDefinitions_MethodsAndProperties =
|> withLangVersionPreview
|> typecheck
|> shouldFail
|> withSingleDiagnostic (Warning 3581, Line 5, Col 14, Line 5, Col 17, "An indexed property's getter and setter must have the same type. Property 'Item' has getter of type 'string' but setter of type 'float'.")
|> withDiagnostics [
(Warning 3581, Line 9, Col 14, Line 9, Col 17, "An indexed property's getter and setter must have the same type. Property 'Indexer2' has getter of type 'int' but setter of type 'float'.")
(Warning 3581, Line 5, Col 14, Line 5, Col 17, "An indexed property's getter and setter must have the same type. Property 'Indexer1' has getter of type 'string' but setter of type 'float'.")
(Warning 3581, Line 18, Col 14, Line 18, Col 17, "An indexed property's getter and setter must have the same type. Property 'Indexer4' has getter of type 'float' but setter of type 'string'.")
(Warning 3581, Line 12, Col 14, Line 12, Col 22, "An indexed property's getter and setter must have the same type. Property 'Indexer3' has getter of type 'int' but setter of type 'float'.")
(Warning 3581, Line 22, Col 14, Line 22, Col 17, "An indexed property's getter and setter must have the same type. Property 'Indexer5' has getter of type 'float' but setter of type 'obj'.")
(Warning 3581, Line 32, Col 27, Line 32, Col 30, "An indexed property's getter and setter must have the same type. Property 'Item' has getter of type ''indexerOutput' but setter of type ''indexerInput'.")
]

// SOURCE=E_AbstractAndConcereteProp.fs SCFLAGS="--test:ErrorRanges" # E_AbstractAndConcereteProp.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AbstractAndConcereteProp.fs"|])>]

0 comments on commit c0b433c

Please sign in to comment.