Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxTreeTests: use short ranges #14739

Merged
merged 3 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Compiler/Optimize/LowerStateMachines.fs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ type LowerStateMachine(g: TcGlobals) =
let res =
match expr with
| ResumableCodeInvoke g (_, _, _, m, _) ->
Result.Error (FSComp.SR.reprResumableCodeInvokeNotReduced(m.ToShortString()))
Result.Error (FSComp.SR.reprResumableCodeInvokeNotReduced(m.ToString()))

// Eliminate 'if __useResumableCode ...' within.
| IfUseResumableStateMachinesExpr g (thenExpr, _) ->
Expand Down
6 changes: 3 additions & 3 deletions src/Compiler/Service/ServiceParseTreeWalk.fs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ module SyntaxTraversal =
#endif
if not isOrdered then
let s =
sprintf "ServiceParseTreeWalk: not isOrdered: %A" (diveResults |> List.map (fun (r, _) -> r.ToShortString()))
sprintf "ServiceParseTreeWalk: not isOrdered: %A" (diveResults |> List.map (fun (r, _) -> r.ToString()))

ignore s
//System.Diagnostics.Debug.Assert(false, s)
Expand All @@ -237,8 +237,8 @@ module SyntaxTraversal =
let s =
sprintf
"ServiceParseTreeWalk: not outerContainsInner: %A : %A"
(outerRange.ToShortString())
(diveResults |> List.map (fun (r, _) -> r.ToShortString()))
(outerRange.ToString())
(diveResults |> List.map (fun (r, _) -> r.ToString()))

ignore s
//System.Diagnostics.Debug.Assert(false, s)
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/TypedTree/TypedTree.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4831,7 +4831,7 @@ type Expr =
| WitnessArg _ -> "WitnessArg(..)"
| TyChoose _ -> "TyChoose(..)"
| Link e -> "Link(" + e.Value.ToDebugString(depth) + ")"
| DebugPoint (DebugPointAtLeafExpr.Yes m, e) -> sprintf "DebugPoint(%s, " (m.ToShortString()) + e.ToDebugString(depth) + ")"
| DebugPoint (DebugPointAtLeafExpr.Yes m, e) -> sprintf "DebugPoint(%s, " (m.ToString()) + e.ToDebugString(depth) + ")"

/// Get the mark/range/position information from an expression
member expr.Range =
Expand Down
5 changes: 1 addition & 4 deletions src/Compiler/Utilities/range.fs
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,6 @@ type Range(code1: int64, code2: int64) =
with e ->
e.ToString()

member m.ToShortString() =
sprintf "(%d,%d--%d,%d)" m.StartLine m.StartColumn m.EndLine m.EndColumn

member _.Equals(m2: range) =
let code2 = code2 &&& ~~~(debugPointKindMask ||| isSyntheticMask)
let rcode2 = m2.Code2 &&& ~~~(debugPointKindMask ||| isSyntheticMask)
Expand All @@ -387,7 +384,7 @@ type Range(code1: int64, code2: int64) =
hash code1 + hash code2

override r.ToString() =
sprintf "%s (%d,%d--%d,%d)" r.FileName r.StartLine r.StartColumn r.EndLine r.EndColumn
sprintf "(%d,%d--%d,%d)" r.StartLine r.StartColumn r.EndLine r.EndColumn
auduchinok marked this conversation as resolved.
Show resolved Hide resolved

and range = Range

Expand Down
3 changes: 0 additions & 3 deletions src/Compiler/Utilities/range.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ type Range =
/// Check if the range is adjacent to another range
member internal IsAdjacentTo: otherRange: Range -> bool

/// Convert a range to string
member internal ToShortString: unit -> string

/// The range where all values are zero
static member Zero: range

Expand Down
2 changes: 1 addition & 1 deletion tests/service/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ let inline dumpDiagnostics (results: FSharpCheckFileResults) =
e.Message.Split('\n')
|> Array.map (fun s -> s.Trim())
|> String.concat " "
sprintf "%s: %s" (e.Range.ToShortString()) message)
sprintf "%s: %s" (e.Range.ToString()) message)
|> List.ofArray

let getSymbolUses (results: FSharpCheckFileResults) =
Expand Down
4 changes: 2 additions & 2 deletions tests/service/ExprTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ module internal Utils =
//printfn "%s" v.CompiledName
// try
if v.IsMember then
sprintf "member %s%s = %s @ %s" v.CompiledName (printCurriedParams vs) (printExpr 0 e) (e.Range.ToShortString())
sprintf "member %s%s = %s @ %s" v.CompiledName (printCurriedParams vs) (printExpr 0 e) (e.Range.ToString())
else
sprintf "let %s%s = %s @ %s" v.CompiledName (printCurriedParams vs) (printExpr 0 e) (e.Range.ToShortString())
sprintf "let %s%s = %s @ %s" v.CompiledName (printCurriedParams vs) (printExpr 0 e) (e.Range.ToString())
// with e ->
// printfn "FAILURE STACK: %A" e
// sprintf "!!!!!!!!!! FAILED on %s @ %s, message: %s" v.CompiledName (v.DeclarationLocation.ToString()) e.Message
Expand Down
33 changes: 10 additions & 23 deletions tests/service/data/SyntaxTree/Attribute/RangeOfAttribute.fs.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,16 @@ ImplFile
SynLongIdent
([op_Equality], [],
[Some (OriginalNotation "=")]), None,
/root/Attribute/RangeOfAttribute.fs (2,18--2,19)),
Ident foo,
/root/Attribute/RangeOfAttribute.fs (2,14--2,19)),
(2,18--2,19)), Ident foo, (2,14--2,19)),
Const
(String
("bar", Regular,
/root/Attribute/RangeOfAttribute.fs (2,19--2,24)),
/root/Attribute/RangeOfAttribute.fs (2,19--2,24)),
/root/Attribute/RangeOfAttribute.fs (2,14--2,24)),
/root/Attribute/RangeOfAttribute.fs (2,13--2,14),
Some /root/Attribute/RangeOfAttribute.fs (2,24--2,25),
/root/Attribute/RangeOfAttribute.fs (2,13--2,25))
(String ("bar", Regular, (2,19--2,24)),
(2,19--2,24)), (2,14--2,24)), (2,13--2,14),
Some (2,24--2,25), (2,13--2,25))
Target = None
AppliesToGetterAndSetter = false
Range = /root/Attribute/RangeOfAttribute.fs (2,2--2,25) }]
Range = /root/Attribute/RangeOfAttribute.fs (2,0--2,27) }],
/root/Attribute/RangeOfAttribute.fs (2,0--2,27));
Expr
(Do
(Const (Unit, /root/Attribute/RangeOfAttribute.fs (3,3--3,5)),
/root/Attribute/RangeOfAttribute.fs (3,0--3,5)),
/root/Attribute/RangeOfAttribute.fs (3,0--3,5))], PreXmlDocEmpty,
[], None, /root/Attribute/RangeOfAttribute.fs (2,0--4,0),
{ LeadingKeyword = None })], (true, false),
{ ConditionalDirectives = []
CodeComments = [] }, set []))
Range = (2,2--2,25) }]
Range = (2,0--2,27) }], (2,0--2,27));
Expr (Do (Const (Unit, (3,3--3,5)), (3,0--3,5)), (3,0--3,5))],
PreXmlDocEmpty, [], None, (2,0--4,0), { LeadingKeyword = None })],
(true, false), { ConditionalDirectives = []
CodeComments = [] }, set []))
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ ImplFile
([{ Attributes =
[{ TypeName =
SynLongIdent
([Prefix; MyAttribute],
[/root/Attribute/RangeOfAttributeWithPath.fs (2,8--2,9)],
[None; None])
([Prefix; MyAttribute], [(2,8--2,9)], [None; None])
ArgExpr =
Paren
(App
Expand All @@ -22,33 +20,16 @@ ImplFile
SynLongIdent
([op_Equality], [],
[Some (OriginalNotation "=")]), None,
/root/Attribute/RangeOfAttributeWithPath.fs (2,25--2,26)),
Ident foo,
/root/Attribute/RangeOfAttributeWithPath.fs (2,21--2,26)),
(2,25--2,26)), Ident foo, (2,21--2,26)),
Const
(String
("bar", Regular,
/root/Attribute/RangeOfAttributeWithPath.fs (2,26--2,31)),
/root/Attribute/RangeOfAttributeWithPath.fs (2,26--2,31)),
/root/Attribute/RangeOfAttributeWithPath.fs (2,21--2,31)),
/root/Attribute/RangeOfAttributeWithPath.fs (2,20--2,21),
Some
/root/Attribute/RangeOfAttributeWithPath.fs (2,31--2,32),
/root/Attribute/RangeOfAttributeWithPath.fs (2,20--2,32))
(String ("bar", Regular, (2,26--2,31)),
(2,26--2,31)), (2,21--2,31)), (2,20--2,21),
Some (2,31--2,32), (2,20--2,32))
Target = None
AppliesToGetterAndSetter = false
Range =
/root/Attribute/RangeOfAttributeWithPath.fs (2,2--2,32) }]
Range = /root/Attribute/RangeOfAttributeWithPath.fs (2,0--2,34) }],
/root/Attribute/RangeOfAttributeWithPath.fs (2,0--2,34));
Expr
(Do
(Const
(Unit, /root/Attribute/RangeOfAttributeWithPath.fs (3,3--3,5)),
/root/Attribute/RangeOfAttributeWithPath.fs (3,0--3,5)),
/root/Attribute/RangeOfAttributeWithPath.fs (3,0--3,5))],
PreXmlDocEmpty, [], None,
/root/Attribute/RangeOfAttributeWithPath.fs (2,0--4,0),
{ LeadingKeyword = None })], (true, false),
{ ConditionalDirectives = []
CodeComments = [] }, set []))
Range = (2,2--2,32) }]
Range = (2,0--2,34) }], (2,0--2,34));
Expr (Do (Const (Unit, (3,3--3,5)), (3,0--3,5)), (3,0--3,5))],
PreXmlDocEmpty, [], None, (2,0--4,0), { LeadingKeyword = None })],
(true, false), { ConditionalDirectives = []
CodeComments = [] }, set []))
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,16 @@ ImplFile
SynLongIdent
([op_Equality], [],
[Some (OriginalNotation "=")]), None,
/root/Attribute/RangeOfAttributeWithTarget.fs (2,28--2,29)),
Ident foo,
/root/Attribute/RangeOfAttributeWithTarget.fs (2,24--2,29)),
(2,28--2,29)), Ident foo, (2,24--2,29)),
Const
(String
("bar", Regular,
/root/Attribute/RangeOfAttributeWithTarget.fs (2,29--2,34)),
/root/Attribute/RangeOfAttributeWithTarget.fs (2,29--2,34)),
/root/Attribute/RangeOfAttributeWithTarget.fs (2,24--2,34)),
/root/Attribute/RangeOfAttributeWithTarget.fs (2,23--2,24),
Some
/root/Attribute/RangeOfAttributeWithTarget.fs (2,34--2,35),
/root/Attribute/RangeOfAttributeWithTarget.fs (2,23--2,35))
(String ("bar", Regular, (2,29--2,34)),
(2,29--2,34)), (2,24--2,34)), (2,23--2,24),
Some (2,34--2,35), (2,23--2,35))
Target = Some assembly
AppliesToGetterAndSetter = false
Range =
/root/Attribute/RangeOfAttributeWithTarget.fs (2,2--2,35) }]
Range =
/root/Attribute/RangeOfAttributeWithTarget.fs (2,0--2,37) }],
/root/Attribute/RangeOfAttributeWithTarget.fs (2,0--2,37));
Expr
(Do
(Const
(Unit,
/root/Attribute/RangeOfAttributeWithTarget.fs (3,3--3,5)),
/root/Attribute/RangeOfAttributeWithTarget.fs (3,0--3,5)),
/root/Attribute/RangeOfAttributeWithTarget.fs (3,0--3,5))],
PreXmlDocEmpty, [], None,
/root/Attribute/RangeOfAttributeWithTarget.fs (2,0--4,0),
{ LeadingKeyword = None })], (true, false),
{ ConditionalDirectives = []
CodeComments = [] }, set []))
Range = (2,2--2,35) }]
Range = (2,0--2,37) }], (2,0--2,37));
Expr (Do (Const (Unit, (3,3--3,5)), (3,0--3,5)), (3,0--3,5))],
PreXmlDocEmpty, [], None, (2,0--4,0), { LeadingKeyword = None })],
(true, false), { ConditionalDirectives = []
CodeComments = [] }, set []))
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,23 @@ ImplFile
SynArgInfo ([], false, None)), None),
LongIdent
(SynLongIdent ([x], [], [None]), None, None,
Pats
[Named
(SynIdent (y, None), false, None,
/root/Binding/ColonBeforeReturnTypeIsPartOfTrivia.fs (2,6--2,7))],
None,
/root/Binding/ColonBeforeReturnTypeIsPartOfTrivia.fs (2,4--2,7)),
Pats [Named (SynIdent (y, None), false, None, (2,6--2,7))],
None, (2,4--2,7)),
Some
(SynBindingReturnInfo
(LongIdent (SynLongIdent ([int], [], [None])),
/root/Binding/ColonBeforeReturnTypeIsPartOfTrivia.fs (2,10--2,13),
[],
{ ColonRange =
Some
/root/Binding/ColonBeforeReturnTypeIsPartOfTrivia.fs (2,8--2,9) })),
(2,10--2,13), [], { ColonRange = Some (2,8--2,9) })),
Typed
(App
(NonAtomic, false, Ident failwith,
Const
(String
("todo", Regular,
/root/Binding/ColonBeforeReturnTypeIsPartOfTrivia.fs (2,25--2,31)),
/root/Binding/ColonBeforeReturnTypeIsPartOfTrivia.fs (2,25--2,31)),
/root/Binding/ColonBeforeReturnTypeIsPartOfTrivia.fs (2,16--2,31)),
LongIdent (SynLongIdent ([int], [], [None])),
/root/Binding/ColonBeforeReturnTypeIsPartOfTrivia.fs (2,16--2,31)),
/root/Binding/ColonBeforeReturnTypeIsPartOfTrivia.fs (2,4--2,7),
NoneAtLet,
{ LeadingKeyword =
Let
/root/Binding/ColonBeforeReturnTypeIsPartOfTrivia.fs (2,0--2,3)
InlineKeyword = None
EqualsRange =
Some
/root/Binding/ColonBeforeReturnTypeIsPartOfTrivia.fs (2,14--2,15) })],
/root/Binding/ColonBeforeReturnTypeIsPartOfTrivia.fs (2,0--2,31))],
PreXmlDocEmpty, [], None,
/root/Binding/ColonBeforeReturnTypeIsPartOfTrivia.fs (2,0--3,0),
(String ("todo", Regular, (2,25--2,31)), (2,25--2,31)),
(2,16--2,31)),
LongIdent (SynLongIdent ([int], [], [None])), (2,16--2,31)),
(2,4--2,7), NoneAtLet, { LeadingKeyword = Let (2,0--2,3)
InlineKeyword = None
EqualsRange = Some (2,14--2,15) })],
(2,0--2,31))], PreXmlDocEmpty, [], None, (2,0--3,0),
{ LeadingKeyword = None })], (true, false),
{ ConditionalDirectives = []
CodeComments = [] }, set []))
Loading