Skip to content

Commit c0002cc

Browse files
auduchinokbaronfel
authored andcommitted
Don't try to print startupRange file contents in debug (#7898)
1 parent cc161ad commit c0002cc

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/fsharp/TcGlobals.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ open FSharp.Compiler.Features
2626

2727
open Internal.Utilities
2828

29-
let internal DummyFileNameForRangesWithoutASpecificLocation = "startup"
29+
let internal DummyFileNameForRangesWithoutASpecificLocation = startupFileName
3030
let private envRange = rangeN DummyFileNameForRangesWithoutASpecificLocation 0
3131

3232
/// Represents an intrinsic value from FSharp.Core known to the compiler

src/fsharp/range.fs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ let fileOfFileIndex idx = fileIndexTable.IndexToFile idx
200200

201201
let mkPos l c = pos (l, c)
202202

203+
let unknownFileName = "unknown"
204+
let startupFileName = "startup"
205+
let commandLineArgsFileName = "commandLineArgs"
206+
203207
[<Struct; CustomEquality; NoComparison>]
204208
#if DEBUG
205209
[<System.Diagnostics.DebuggerDisplay("({StartLine},{StartColumn}-{EndLine},{EndColumn}) {FileName} IsSynthetic={IsSynthetic} -> {DebugCode}")>]
@@ -249,6 +253,9 @@ type range(code1:int64, code2: int64) =
249253

250254
#if DEBUG
251255
member r.DebugCode =
256+
let name = r.FileName
257+
if name = unknownFileName || name = startupFileName || name = commandLineArgsFileName then name else
258+
252259
try
253260
let endCol = r.EndColumn - 1
254261
let startCol = r.StartColumn - 1
@@ -323,11 +330,11 @@ let rangeN filename line = mkRange filename (mkPos line 0) (mkPos line 0)
323330

324331
let pos0 = mkPos 1 0
325332

326-
let range0 = rangeN "unknown" 1
333+
let range0 = rangeN unknownFileName 1
327334

328-
let rangeStartup = rangeN "startup" 1
335+
let rangeStartup = rangeN startupFileName 1
329336

330-
let rangeCmdArgs = rangeN "commandLineArgs" 0
337+
let rangeCmdArgs = rangeN commandLineArgsFileName 0
331338

332339
let trimRangeToLine (r:range) =
333340
let startL, startC = r.StartLine, r.StartColumn

src/fsharp/range.fsi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ val mkPos : line:int -> column:int -> pos
4444
/// Ordering on positions
4545
val posOrder : IComparer<pos>
4646

47+
val unknownFileName: string
48+
val startupFileName: string
49+
val commandLineArgsFileName: string
50+
4751
/// Represents a range within a known file
4852
[<Struct; CustomEquality; NoComparison>]
4953
type range =

0 commit comments

Comments
 (0)