Skip to content

Commit 4b61787

Browse files
committed
docs
1 parent 6969538 commit 4b61787

File tree

2 files changed

+37
-32
lines changed

2 files changed

+37
-32
lines changed

src/Compiler/Symbols/FSharpDiagnostic.fs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,21 @@ open FSharp.Compiler.Text
2929
open FSharp.Compiler.Text.Position
3030
open FSharp.Compiler.Text.Range
3131

32-
[<Experimental("This FCS API is experimental and subject to change.")>]
32+
[<RequireQualifiedAccess; Experimental("This FCS API is experimental and subject to change.")>]
3333
type DiagnosticContextInfo =
34-
/// No context was given.
3534
| NoContext
36-
/// The type equation comes from an IF expression.
3735
| IfExpression
38-
/// The type equation comes from an omitted else branch.
3936
| OmittedElseBranch
40-
/// The type equation comes from a type check of the result of an else branch.
4137
| ElseBranchResult
42-
/// The type equation comes from the verification of record fields.
4338
| RecordFields
44-
/// The type equation comes from the verification of a tuple in record fields.
4539
| TupleInRecordFields
46-
/// The type equation comes from a list or array constructor
4740
| CollectionElement
48-
/// The type equation comes from a return in a computation expression.
4941
| ReturnInComputationExpression
50-
/// The type equation comes from a yield in a computation expression.
5142
| YieldInComputationExpression
52-
/// The type equation comes from a runtime type test.
5343
| RuntimeTypeTest
54-
/// The type equation comes from an downcast where a upcast could be used.
5544
| DowncastUsedInsteadOfUpcast
56-
/// The type equation comes from a return type of a pattern match clause (not the first clause).
5745
| FollowingPatternMatchClause
58-
/// The type equation comes from a pattern match guard.
5946
| PatternMatchGuard
60-
/// The type equation comes from a sequence expression.
6147
| SequenceExpression
6248
with
6349
static member From(contextInfo: ContextInfo) =
@@ -188,7 +174,7 @@ type FSharpDiagnostic(m: range, severity: FSharpDiagnosticSeverity, message: str
188174
Some(TypeMismatchDiagnosticExtendedData(symbolEnv, displayEnv, expectedType, actualType, context))
189175

190176
| ErrorFromAddingTypeEquation(_, displayEnv, expectedType, actualType, _, _)->
191-
Some(TypeMismatchDiagnosticExtendedData(symbolEnv, displayEnv, expectedType, actualType, NoContext))
177+
Some(TypeMismatchDiagnosticExtendedData(symbolEnv, displayEnv, expectedType, actualType, DiagnosticContextInfo.NoContext))
192178

193179
| FunctionValueUnexpected(_, actualType, _) ->
194180
Some(ExpressionIsAFunctionExtendedData(symbolEnv, actualType))

src/Compiler/Symbols/FSharpDiagnostic.fsi

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,73 +11,91 @@ open FSharp.Compiler.Symbols
1111
open FSharp.Compiler.Text
1212
open FSharp.Compiler.DiagnosticsLogger
1313

14+
/// Information about the context of a type equation in type-mismatch-like diagnostic
1415
[<RequireQualifiedAccess; Experimental("This FCS API is experimental and subject to change.")>]
1516
type public DiagnosticContextInfo =
16-
/// No context was given.
17+
/// No context was given
1718
| NoContext
18-
/// The type equation comes from an IF expression.
19+
/// The type equation comes from an IF expression
1920
| IfExpression
20-
/// The type equation comes from an omitted else branch.
21+
/// The type equation comes from an omitted else branch
2122
| OmittedElseBranch
22-
/// The type equation comes from a type check of the result of an else branch.
23+
/// The type equation comes from a type check of the result of an else branch
2324
| ElseBranchResult
24-
/// The type equation comes from the verification of record fields.
25+
/// The type equation comes from the verification of record fields
2526
| RecordFields
26-
/// The type equation comes from the verification of a tuple in record fields.
27+
/// The type equation comes from the verification of a tuple in record fields
2728
| TupleInRecordFields
2829
/// The type equation comes from a list or array constructor
2930
| CollectionElement
30-
/// The type equation comes from a return in a computation expression.
31+
/// The type equation comes from a return in a computation expression
3132
| ReturnInComputationExpression
32-
/// The type equation comes from a yield in a computation expression.
33+
/// The type equation comes from a yield in a computation expression
3334
| YieldInComputationExpression
34-
/// The type equation comes from a runtime type test.
35+
/// The type equation comes from a runtime type test
3536
| RuntimeTypeTest
36-
/// The type equation comes from an downcast where a upcast could be used.
37+
/// The type equation comes from an downcast where a upcast could be used
3738
| DowncastUsedInsteadOfUpcast
38-
/// The type equation comes from a return type of a pattern match clause (not the first clause).
39+
/// The type equation comes from a return type of a pattern match clause (not the first clause)
3940
| FollowingPatternMatchClause
40-
/// The type equation comes from a pattern match guard.
41+
/// The type equation comes from a pattern match guard
4142
| PatternMatchGuard
42-
/// The type equation comes from a sequence expression.
43+
/// The type equation comes from a sequence expression
4344
| SequenceExpression
4445

46+
/// Contextually-relevant data to each particular diagnostic
4547
[<Interface; Experimental("This FCS API is experimental and subject to change.")>]
46-
type public IFSharpDiagnosticExtendedData =
47-
interface
48-
end
48+
type public IFSharpDiagnosticExtendedData = interface end
4949

50+
/// Additional data for type-mismatch-like (usually with ErrorNumber = 1) diagnostics
5051
[<Class; Experimental("This FCS API is experimental and subject to change.")>]
5152
type public TypeMismatchDiagnosticExtendedData =
5253
interface IFSharpDiagnosticExtendedData
54+
/// Represents F# type expected in the current context
5355
member ExpectedType: FSharpType
56+
/// Represents F# type type actual in the current context
5457
member ActualType: FSharpType
58+
/// The context in which the type mismatch was found
5559
member ContextInfo: DiagnosticContextInfo
60+
/// Represents the information needed to format types
5661
member DisplayContext: FSharpDisplayContext
5762

63+
/// Additional data for 'This expression is a function value, i.e. is missing arguments' diagnostic
5864
[<Class; Experimental("This FCS API is experimental and subject to change.")>]
5965
type public ExpressionIsAFunctionExtendedData =
6066
interface IFSharpDiagnosticExtendedData
67+
/// Represents F# type of the expression
6168
member ActualType: FSharpType
6269

70+
/// Additional data for diagnostics about a field whose declarations differ in signature and implementation
6371
[<Class; Experimental("This FCS API is experimental and subject to change.")>]
6472
type public FieldNotContainedDiagnosticExtendedData =
6573
interface IFSharpDiagnosticExtendedData
74+
/// Represents F# field in signature file
6675
member SignatureField: FSharpField
76+
/// Represents F# field in implementation file
6777
member ImplementationField: FSharpField
6878

79+
/// Additional data for diagnostics about a value whose declarations differ in signature and implementation
6980
[<Class; Experimental("This FCS API is experimental and subject to change.")>]
7081
type public ValueNotContainedDiagnosticExtendedData =
7182
interface IFSharpDiagnosticExtendedData
83+
/// Represents F# value in signature file
7284
member SignatureValue: FSharpMemberOrFunctionOrValue
85+
/// Represents F# value in implementation file
7386
member ImplementationValue: FSharpMemberOrFunctionOrValue
7487

88+
/// Additional data for 'argument names in the signature and implementation do not match' diagnostic
7589
[<Class; Experimental("This FCS API is experimental and subject to change.")>]
7690
type ArgumentsInSigAndImplMismatchExtendedData =
7791
interface IFSharpDiagnosticExtendedData
92+
/// Argument name in signature file
7893
member SignatureName: string
94+
/// Argument name in implementation file
7995
member ImplementationName: string
96+
/// Argument identifier range within signature file
8097
member SignatureRange: range
98+
/// Argument identifier range within implementation file
8199
member ImplementationRange: range
82100

83101
/// Represents a diagnostic produced by the F# compiler
@@ -126,6 +144,7 @@ type public FSharpDiagnostic =
126144
/// Gets the full error number text e.g "FS0031"
127145
member ErrorNumberText: string
128146

147+
/// Gets the contextually-relevant data to each particular diagnostic for things like code fixes
129148
[<Experimental("This FCS API is experimental and subject to change.")>]
130149
member ExtendedData: IFSharpDiagnosticExtendedData option
131150

0 commit comments

Comments
 (0)