Skip to content

Commit 690fdc4

Browse files
auduchinokKevinRansom
authored andcommitted
Do not trim error ranges (#3892)
* Do not trim error ranges (fixes #3685) * Remove a mention of the Error List window in an error message
1 parent 578db47 commit 690fdc4

File tree

10 files changed

+34
-35
lines changed

10 files changed

+34
-35
lines changed

src/fsharp/FSComp.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ csCtorHasNoArgumentOrReturnProperty,"The object constructor '%s' has no argument
361361
csNoOverloadsFound,"No overloads match for method '%s'."
362362
csMethodIsOverloaded,"A unique overload for method '%s' could not be determined based on type information prior to this program point. A type annotation may be needed."
363363
csCandidates,"Candidates: %s"
364-
csSeeAvailableOverloads,"The available overloads are shown below (or in the Error List window)."
364+
csSeeAvailableOverloads,"The available overloads are shown below."
365365
512,parsDoCannotHaveVisibilityDeclarations,"Accessibility modifiers are not permitted on 'do' bindings, but '%s' was given."
366366
513,parsEofInHashIf,"End of file in #if section begun at or after here"
367367
514,parsEofInString,"End of file in string begun at or before here"

src/fsharp/symbols/SymbolHelpers.fs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,15 @@ type FSharpErrorInfo(fileName, s: pos, e: pos, severity: FSharpErrorSeverity, me
6262
override __.ToString()= sprintf "%s (%d,%d)-(%d,%d) %s %s %s" fileName (int s.Line) (s.Column + 1) (int e.Line) (e.Column + 1) subcategory (if severity=FSharpErrorSeverity.Warning then "warning" else "error") message
6363

6464
/// Decompose a warning or error into parts: position, severity, message, error number
65-
static member CreateFromException(exn, isError, trim:bool, fallbackRange:range) =
65+
static member CreateFromException(exn, isError, fallbackRange:range) =
6666
let m = match GetRangeOfDiagnostic exn with Some m -> m | None -> fallbackRange
67-
let e = if trim then m.Start else m.End
6867
let msg = bufs (fun buf -> OutputPhasedDiagnostic buf exn false)
6968
let errorNum = GetDiagnosticNumber exn
70-
FSharpErrorInfo(m.FileName, m.Start, e, (if isError then FSharpErrorSeverity.Error else FSharpErrorSeverity.Warning), msg, exn.Subcategory(), errorNum)
69+
FSharpErrorInfo(m.FileName, m.Start, m.End, (if isError then FSharpErrorSeverity.Error else FSharpErrorSeverity.Warning), msg, exn.Subcategory(), errorNum)
7170

7271
/// Decompose a warning or error into parts: position, severity, message, error number
73-
static member CreateFromExceptionAndAdjustEof(exn, isError, trim:bool, fallbackRange:range, (linesCount:int, lastLength:int)) =
74-
let r = FSharpErrorInfo.CreateFromException(exn, isError, trim, fallbackRange)
72+
static member CreateFromExceptionAndAdjustEof(exn, isError, fallbackRange:range, (linesCount:int, lastLength:int)) =
73+
let r = FSharpErrorInfo.CreateFromException(exn, isError, fallbackRange)
7574

7675
// Adjust to make sure that errors reported at Eof are shown at the linesCount
7776
let startline, schange = min (r.StartLineAlternate, false) (linesCount, true)
@@ -93,7 +92,7 @@ type ErrorScope() =
9392
PushErrorLoggerPhaseUntilUnwind (fun _oldLogger ->
9493
{ new ErrorLogger("ErrorScope") with
9594
member x.DiagnosticSink(exn, isError) =
96-
let err = FSharpErrorInfo.CreateFromException(exn, isError, false, range.Zero)
95+
let err = FSharpErrorInfo.CreateFromException(exn, isError, range.Zero)
9796
errors <- err :: errors
9897
if isError && firstError.IsNone then
9998
firstError <- Some err.Message
@@ -180,18 +179,18 @@ module ErrorHelpers =
180179
let ReportError (options, allErrors, mainInputFileName, fileInfo, (exn, sev)) =
181180
[ let isError = (sev = FSharpErrorSeverity.Error) || ReportWarningAsError options exn
182181
if (isError || ReportWarning options exn) then
183-
let oneError trim exn =
182+
let oneError exn =
184183
[ // We use the first line of the file as a fallbackRange for reporting unexpected errors.
185184
// Not ideal, but it's hard to see what else to do.
186185
let fallbackRange = rangeN mainInputFileName 1
187-
let ei = FSharpErrorInfo.CreateFromExceptionAndAdjustEof (exn, isError, trim, fallbackRange, fileInfo)
186+
let ei = FSharpErrorInfo.CreateFromExceptionAndAdjustEof (exn, isError, fallbackRange, fileInfo)
188187
if allErrors || (ei.FileName = mainInputFileName) || (ei.FileName = TcGlobals.DummyFileNameForRangesWithoutASpecificLocation) then
189188
yield ei ]
190189

191190
let mainError, relatedErrors = SplitRelatedDiagnostics exn
192-
yield! oneError false mainError
191+
yield! oneError mainError
193192
for e in relatedErrors do
194-
yield! oneError true e ]
193+
yield! oneError e ]
195194

196195
let CreateErrorInfos (options, allErrors, mainInputFileName, errors) =
197196
let fileInfo = (Int32.MaxValue, Int32.MaxValue)

src/fsharp/symbols/SymbolHelpers.fsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ type internal FSharpErrorInfo =
4646
member Message:string
4747
member Subcategory:string
4848
member ErrorNumber:int
49-
static member internal CreateFromExceptionAndAdjustEof : PhasedDiagnostic * isError: bool * trim: bool * range * lastPosInFile:(int*int) -> FSharpErrorInfo
50-
static member internal CreateFromException : PhasedDiagnostic * isError: bool * trim: bool * range -> FSharpErrorInfo
49+
static member internal CreateFromExceptionAndAdjustEof : PhasedDiagnostic * isError: bool * range * lastPosInFile:(int*int) -> FSharpErrorInfo
50+
static member internal CreateFromException : PhasedDiagnostic * isError: bool * range -> FSharpErrorInfo
5151

5252
//----------------------------------------------------------------------------
5353
// Object model for quick info

src/fsharp/vs/service.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,10 +2104,10 @@ module CompileHelpers =
21042104
let errors = ResizeArray<_>()
21052105

21062106
let errorSink isError exn =
2107-
let mainError,relatedErrors = SplitRelatedDiagnostics exn
2108-
let oneError trim e = errors.Add(FSharpErrorInfo.CreateFromException (e, isError, trim, Range.range0))
2109-
oneError false mainError
2110-
List.iter (oneError true) relatedErrors
2107+
let mainError, relatedErrors = SplitRelatedDiagnostics exn
2108+
let oneError e = errors.Add(FSharpErrorInfo.CreateFromException (e, isError, Range.range0))
2109+
oneError mainError
2110+
List.iter oneError relatedErrors
21112111

21122112
let errorLogger =
21132113
{ new ErrorLogger("CompileAPI") with

tests/fsharp/typecheck/sigs/neg20.bsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ neg20.fs(129,19,129,22): typecheck error FS0001: This expression was expected to
159159
but here has type
160160
'string'
161161

162-
neg20.fs(131,5,131,24): typecheck error FS0041: No overloads match for method 'OM3'. The available overloads are shown below (or in the Error List window).
162+
neg20.fs(131,5,131,24): typecheck error FS0041: No overloads match for method 'OM3'. The available overloads are shown below.
163163
neg20.fs(131,5,131,24): typecheck error FS0041: Possible overload: 'static member C.OM3 : x:'b * y:int -> int'. Type constraint mismatch. The type
164164
'obj'
165165
is not compatible with type
@@ -199,7 +199,7 @@ neg20.fs(166,13,166,35): typecheck error FS0502: The member or object constructo
199199

200200
neg20.fs(167,13,167,31): typecheck error FS0502: The member or object constructor 'M5' takes 2 type argument(s) but is here given 1. The required signature is 'member C.M5 : y:'a * z:'b -> int'.
201201

202-
neg20.fs(182,14,182,31): typecheck error FS0041: No overloads match for method 'M'. The available overloads are shown below (or in the Error List window).
202+
neg20.fs(182,14,182,31): typecheck error FS0041: No overloads match for method 'M'. The available overloads are shown below.
203203
neg20.fs(182,14,182,31): typecheck error FS0041: Possible overload: 'static member C2.M : fmt:string * [<System.ParamArray>] args:int [] -> string'. Type constraint mismatch. The type
204204
'obj'
205205
is not compatible with type
@@ -236,7 +236,7 @@ neg20.fs(184,34,184,39): typecheck error FS0001: This expression was expected to
236236
but here has type
237237
'obj'
238238

239-
neg20.fs(188,14,188,31): typecheck error FS0041: No overloads match for method 'M'. The available overloads are shown below (or in the Error List window).
239+
neg20.fs(188,14,188,31): typecheck error FS0041: No overloads match for method 'M'. The available overloads are shown below.
240240
neg20.fs(188,14,188,31): typecheck error FS0041: Possible overload: 'static member C3.M : fmt:string * [<System.ParamArray>] args:string [] -> string'. Type constraint mismatch. The type
241241
'obj'
242242
is not compatible with type

tests/fsharp/typecheck/sigs/neg61.bsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ neg61.fs(156,21,156,22): typecheck error FS3147: This 'let' definition may not b
8383

8484
neg61.fs(171,13,171,18): typecheck error FS3099: 'sumBy' is used with an incorrect number of arguments. This is a custom operation in this query or computation expression. Expected 1 argument(s), but given 0.
8585

86-
neg61.fs(174,22,174,23): typecheck error FS0041: No overloads match for method 'Source'. The available overloads are shown below (or in the Error List window).
86+
neg61.fs(174,22,174,23): typecheck error FS0041: No overloads match for method 'Source'. The available overloads are shown below.
8787
neg61.fs(174,22,174,23): typecheck error FS0041: Possible overload: 'member Linq.QueryBuilder.Source : source:System.Linq.IQueryable<'T> -> Linq.QuerySource<'T,'Q>'. Type constraint mismatch. The type
8888
'int'
8989
is not compatible with type

tests/fsharpqa/Source/Conformance/Expressions/Type-relatedExpressions/E_RigidTypeAnnotation03.fsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ let _ = T.M( @"\" : char )
2323
exit 1
2424
// Way more errors are reported, but this is a good enough list.
2525
//<Expects id="FS0001" span="(17,13-17,16)" status="error">This expression was expected to have type. 'sbyte' .but here has type. 'byte'</Expects>
26-
//<Expects id="FS0041" span="(17,9-17,25)" status="error">No overloads match for method 'M'\. The available overloads are shown below \(or in the Error List window\)\.</Expects>
26+
//<Expects id="FS0041" span="(17,9-17,25)" status="error">No overloads match for method 'M'\. The available overloads are shown below\.</Expects>
2727
//<Expects id="FS0001" span="(18,13-18,19)" status="error">This expression was expected to have type. 'float32' .but here has type. 'float<'u>'</Expects>
28-
//<Expects id="FS0041" span="(18,9-18,30)" status="error">No overloads match for method 'M'\. The available overloads are shown below \(or in the Error List window\)\.</Expects>
28+
//<Expects id="FS0041" span="(18,9-18,30)" status="error">No overloads match for method 'M'\. The available overloads are shown below\.</Expects>
2929
//<Expects id="FS0001" span="(19,13-19,20)" status="error">This expression was expected to have type. 'float32<'u>' .but here has type. 'decimal<s>'</Expects>
3030
//<Expects id="FS0001" span="(20,13-20,21)" status="error">Type mismatch\. Expecting a. 'decimal<N s \^ 2>' .but given a. 'decimal<Kg>'</Expects>
31-
//<Expects id="FS0041" span="(20,9-20,39)" status="error">No overloads match for method 'M'\. The available overloads are shown below \(or in the Error List window\)\.</Expects>
31+
//<Expects id="FS0041" span="(20,9-20,39)" status="error">No overloads match for method 'M'\. The available overloads are shown below\.</Expects>
3232
//<Expects id="FS0001" span="(21,14-21,18)" status="error">This expression was expected to have type. 'char' .but here has type. 'string'</Expects>
33-
//<Expects id="FS0041" span="(21,9-21,27)" status="error">No overloads match for method 'M'\. The available overloads are shown below \(or in the Error List window\)\.</Expects>
33+
//<Expects id="FS0041" span="(21,9-21,27)" status="error">No overloads match for method 'M'\. The available overloads are shown below\.</Expects>

tests/fsharpqa/Source/Conformance/InferenceProcedures/TypeInference/E_TwoDifferentTypeVariablesGen00.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
//<Expects id="FS0001" span="(105,48-105,49)" status="error">This expression was expected to have type. 'int' .but here has type. ''b'</Expects>
88
//<Expects id="FS0001" span="(106,48-106,49)" status="error">A type parameter is missing a constraint 'when 'b :> C'</Expects>
99
//<Expects id="FS0193" span="(106,48-106,49)" status="error">Type constraint mismatch. The type.+''b'.+is not compatible with type</Expects>
10-
//<Expects id="FS0041" span="(107,41-107,51)" status="error">No overloads match for method 'M'\. The available overloads are shown below \(or in the Error List window\)\.</Expects>
10+
//<Expects id="FS0041" span="(107,41-107,51)" status="error">No overloads match for method 'M'\. The available overloads are shown below\.</Expects>
1111

1212

1313

14-
//<Expects id="FS0041" span="(108,41-108,51)" status="error">No overloads match for method 'M'\. The available overloads are shown below \(or in the Error List window\)\.</Expects>
14+
//<Expects id="FS0041" span="(108,41-108,51)" status="error">No overloads match for method 'M'\. The available overloads are shown below\.</Expects>
1515

1616

1717

@@ -20,12 +20,12 @@
2020
//<Expects id="FS0001" span="(110,52-110,53)" status="error">This expression was expected to have type. 'int' .but here has type. ''b'</Expects>
2121
//<Expects id="FS0001" span="(111,52-111,53)" status="error">A type parameter is missing a constraint 'when 'b :> C'</Expects>
2222
//<Expects id="FS0193" span="(111,52-111,53)" status="error">Type constraint mismatch. The type.+''b'.+is not compatible with type</Expects>
23-
//<Expects id="FS0041" span="(112,41-112,55)" status="error">No overloads match for method 'M'\. The available overloads are shown below \(or in the Error List window\)\.</Expects>
23+
//<Expects id="FS0041" span="(112,41-112,55)" status="error">No overloads match for method 'M'\. The available overloads are shown below\.</Expects>
2424

2525

2626

2727

28-
//<Expects id="FS0041" span="(113,41-113,55)" status="error">No overloads match for method 'M'\. The available overloads are shown below \(or in the Error List window\)\.</Expects>
28+
//<Expects id="FS0041" span="(113,41-113,55)" status="error">No overloads match for method 'M'\. The available overloads are shown below\.</Expects>
2929

3030

3131

@@ -34,12 +34,12 @@
3434
//<Expects id="FS0001" span="(115,51-115,52)" status="error">This expression was expected to have type. 'int' .but here has type. ''b'</Expects>
3535
//<Expects id="FS0001" span="(116,51-116,52)" status="error">A type parameter is missing a constraint 'when 'b :> C'</Expects>
3636
//<Expects id="FS0193" span="(116,51-116,52)" status="error">Type constraint mismatch. The type.+''b'.+is not compatible with type</Expects>
37-
//<Expects id="FS0041" span="(117,41-117,54)" status="error">No overloads match for method 'M'\. The available overloads are shown below \(or in the Error List window\)\.</Expects>
37+
//<Expects id="FS0041" span="(117,41-117,54)" status="error">No overloads match for method 'M'\. The available overloads are shown below\.</Expects>
3838

3939

4040

4141

42-
//<Expects id="FS0041" span="(118,41-118,54)" status="error">No overloads match for method 'M'\. The available overloads are shown below \(or in the Error List window\)\.</Expects>
42+
//<Expects id="FS0041" span="(118,41-118,54)" status="error">No overloads match for method 'M'\. The available overloads are shown below\.</Expects>
4343

4444

4545

tests/fsharpqa/Source/Conformance/LexicalAnalysis/SymbolicOperators/E_LessThanDotOpenParen001.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// want to verify we do not crash!
55
//<Expects status="warning" id="FS0064">This construct causes code to be less generic than indicated by the type annotations\. The type variable 'S has been constrained to be type 'int'</Expects>
66
//<Expects status="error" id="FS0670">This code is not sufficiently generic\. The type variable \^T when \^T : \(static member \( \+ \) : \^T \* \^T -> \^a\) could not be generalized because it would escape its scope</Expects>
7-
//<Expects status="error" id="FS0043">No overloads match for method 'op_PlusPlusPlus'\. The available overloads are shown below \(or in the Error List window\)\.</Expects>
8-
//<Expects status="error" id="FS0041">No overloads match for method 'op_PlusPlusPlus'\. The available overloads are shown below \(or in the Error List window\)\.</Expects>
9-
//<Expects status="error" id="FS0041">No overloads match for method 'op_PlusPlusPlus'\. The available overloads are shown below \(or in the Error List window\)\.</Expects>
7+
//<Expects status="error" id="FS0043">No overloads match for method 'op_PlusPlusPlus'\. The available overloads are shown below\.</Expects>
8+
//<Expects status="error" id="FS0041">No overloads match for method 'op_PlusPlusPlus'\. The available overloads are shown below\.</Expects>
9+
//<Expects status="error" id="FS0041">No overloads match for method 'op_PlusPlusPlus'\. The available overloads are shown below\.</Expects>
1010

1111
type public TestType<'T,'S>() =
1212

vsintegration/tests/unittests/Tests.LanguageService.ErrorList.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ let g (t : T) = t.Count()
184184
CheckErrorList content <|
185185
fun errors ->
186186
Assert.AreEqual(3, List.length errors)
187-
assertContains errors "No overloads match for method 'X'. The available overloads are shown below (or in the Error List window)."
187+
assertContains errors "No overloads match for method 'X'. The available overloads are shown below."
188188
for expected in expectedMessages do
189189
errors
190190
|> List.exists (fun e -> e.Message.StartsWith expected)

0 commit comments

Comments
 (0)