From dd1b87db0c0877080d994cb52e8bfce150514ebb Mon Sep 17 00:00:00 2001 From: Phillip Carter Date: Thu, 20 Dec 2018 18:02:01 -0800 Subject: [PATCH 1/4] Override '=' for Range type --- src/fsharp/range.fs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fsharp/range.fs b/src/fsharp/range.fs index 7f31e032a9f..bbb70cc93ce 100755 --- a/src/fsharp/range.fs +++ b/src/fsharp/range.fs @@ -189,12 +189,13 @@ type range(code1:int64, code2: int64) = member r.ToShortString() = sprintf "(%d,%d--%d,%d)" r.StartLine r.StartColumn r.EndLine r.EndColumn - override r.Equals(obj) = match obj with :? range as r2 -> code1 = r2.Code1 && code2 = r2.Code2 | _ -> false - override r.GetHashCode() = hash code1 + hash code2 override r.ToString() = sprintf "%s (%d,%d--%d,%d) IsSynthetic=%b" r.FileName r.StartLine r.StartColumn r.EndLine r.EndColumn r.IsSynthetic + static member op_Equality (x: range, y: range) = + x.Code1 = y.Code1 && x.Code2 = y.Code2 + let mkRange f b e = // remove relative parts from full path let normalizedFilePath = if Path.IsPathRooted f then try Path.GetFullPath f with _ -> f else f From 77ff1799fd0d05e9735743a1d9489cc5974c0cf0 Mon Sep 17 00:00:00 2001 From: Phillip Carter Date: Thu, 20 Dec 2018 18:03:01 -0800 Subject: [PATCH 2/4] Re-add overridden equals because --- src/fsharp/range.fs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fsharp/range.fs b/src/fsharp/range.fs index bbb70cc93ce..001449fdc01 100755 --- a/src/fsharp/range.fs +++ b/src/fsharp/range.fs @@ -189,6 +189,8 @@ type range(code1:int64, code2: int64) = member r.ToShortString() = sprintf "(%d,%d--%d,%d)" r.StartLine r.StartColumn r.EndLine r.EndColumn + override r.Equals(obj) = match obj with :? range as r2 -> code1 = r2.Code1 && code2 = r2.Code2 | _ -> false + override r.GetHashCode() = hash code1 + hash code2 override r.ToString() = sprintf "%s (%d,%d--%d,%d) IsSynthetic=%b" r.FileName r.StartLine r.StartColumn r.EndLine r.EndColumn r.IsSynthetic From b15d68b7646eeb04de545eaf3fa8c859c49942fa Mon Sep 17 00:00:00 2001 From: Phillip Carter Date: Fri, 21 Dec 2018 13:28:47 -0800 Subject: [PATCH 3/4] Replace equality with Range.equals function --- src/fsharp/CompileOps.fs | 12 +++++++--- src/fsharp/NameResolution.fs | 30 ++++++++++++++----------- src/fsharp/TypeChecker.fs | 12 +++++----- src/fsharp/range.fs | 7 +++--- src/fsharp/range.fsi | 2 ++ src/fsharp/service/ServiceNavigation.fs | 5 ++++- 6 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 240afb5a2d2..6ff3b33d554 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -2610,12 +2610,12 @@ type TcConfigBuilder = member tcConfigB.AddReferencedAssemblyByPath (m, path) = if FileSystem.IsInvalidPathShim(path) then warning(Error(FSComp.SR.buildInvalidAssemblyName(path), m)) - elif not (tcConfigB.referencedDLLs |> List.exists (fun ar2 -> m=ar2.Range && path=ar2.Text)) then // NOTE: We keep same paths if range is different. + elif not (tcConfigB.referencedDLLs |> List.exists (fun ar2 -> Range.equals m ar2.Range && path=ar2.Text)) then // NOTE: We keep same paths if range is different. let projectReference = tcConfigB.projectReferences |> List.tryPick (fun pr -> if pr.FileName = path then Some pr else None) tcConfigB.referencedDLLs <- tcConfigB.referencedDLLs ++ AssemblyReference(m, path, projectReference) member tcConfigB.RemoveReferencedAssemblyByPath (m, path) = - tcConfigB.referencedDLLs <- tcConfigB.referencedDLLs |> List.filter (fun ar-> ar.Range <> m || ar.Text <> path) + tcConfigB.referencedDLLs <- tcConfigB.referencedDLLs |> List.filter (fun ar -> not (Range.equals ar.Range m) || ar.Text <> path) static member SplitCommandLineResourceInfo (ri:string) = let p = ri.IndexOf ',' @@ -3110,7 +3110,13 @@ type TcConfig private (data : TcConfigBuilder, validate:bool) = // file is included in the search path. This should ideally already be one of the search paths, but // during some global checks it won't be. We append to the end of the search list so that this is the last // place that is checked. - if m <> range0 && m <> rangeStartup && m <> rangeCmdArgs && FileSystem.IsPathRootedShim m.FileName then + let isPoundRReference (r: range) = + not (Range.equals r range0) && + not (Range.equals r rangeStartup) && + not (Range.equals r rangeCmdArgs) && + FileSystem.IsPathRootedShim r.FileName + + if isPoundRReference m then tcConfig.GetSearchPathsForLibraryFiles() @ [Path.GetDirectoryName(m.FileName)] else tcConfig.GetSearchPathsForLibraryFiles() diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index d3d1c7db881..e2f9874c10f 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -898,7 +898,7 @@ let AddResults res1 res2 = | Exception _,Result l -> Result l | Result x,Exception _ -> Result x // If we have error messages for the same symbol, then we can merge suggestions. - | Exception (UndefinedName(n1,f,id1,suggestions1)),Exception (UndefinedName(n2,_,id2,suggestions2)) when n1 = n2 && id1.idText = id2.idText && id1.idRange = id2.idRange -> + | Exception (UndefinedName(n1,f,id1,suggestions1)),Exception (UndefinedName(n2,_,id2,suggestions2)) when n1 = n2 && id1.idText = id2.idText && Range.equals id1.idRange id2.idRange -> let suggestions = HashSet(suggestions1()) suggestions.UnionWith(suggestions2()) Exception(UndefinedName(n1,f,id1,fun () -> suggestions)) @@ -1354,8 +1354,10 @@ let tyconRefDefnEq g (eref1:EntityRef) (eref2: EntityRef) = tyconRefEq g eref1 eref2 || // Signature items considered equal to implementation items - eref1.DefinitionRange <> Range.rangeStartup && eref1.DefinitionRange <> Range.range0 && eref1.DefinitionRange <> Range.rangeCmdArgs && - (eref1.DefinitionRange = eref2.DefinitionRange || eref1.SigRange = eref2.SigRange) && + not (Range.equals eref1.DefinitionRange Range.rangeStartup) && + not (Range.equals eref1.DefinitionRange Range.range0) && + not (Range.equals eref1.DefinitionRange Range.rangeCmdArgs) && + (Range.equals eref1.DefinitionRange eref2.DefinitionRange || Range.equals eref1.SigRange eref2.SigRange) && eref1.LogicalName = eref2.LogicalName let valRefDefnHash (_g: TcGlobals) (vref1:ValRef) = @@ -1365,8 +1367,10 @@ let valRefDefnEq g (vref1:ValRef) (vref2: ValRef) = valRefEq g vref1 vref2 || // Signature items considered equal to implementation items - vref1.DefinitionRange <> Range.rangeStartup && vref1.DefinitionRange <> Range.range0 && vref1.DefinitionRange <> Range.rangeCmdArgs && - (vref1.DefinitionRange = vref2.DefinitionRange || vref1.SigRange = vref2.SigRange) && + not (Range.equals vref1.DefinitionRange Range.rangeStartup) && + not (Range.equals vref1.DefinitionRange Range.range0) && + not (Range.equals vref1.DefinitionRange Range.rangeCmdArgs) && + (Range.equals vref1.DefinitionRange vref2.DefinitionRange || Range.equals vref1.SigRange vref2.SigRange) && vref1.LogicalName = vref2.LogicalName let unionCaseRefDefnEq g (uc1:UnionCaseRef) (uc2: UnionCaseRef) = @@ -1385,7 +1389,7 @@ let ItemsAreEffectivelyEqual g orig other = | TType_var tp1, TType_var tp2 -> not tp1.IsCompilerGenerated && not tp1.IsFromError && not tp2.IsCompilerGenerated && not tp2.IsFromError && - tp1.Range = tp2.Range + Range.equals tp1.Range tp2.Range | AbbrevOrAppTy tcref1, AbbrevOrAppTy tcref2 -> tyconRefDefnEq g tcref1 tcref2 | _ -> false) @@ -1394,7 +1398,7 @@ let ItemsAreEffectivelyEqual g orig other = valRefDefnEq g vref1 vref2 | ActivePatternCaseUse (range1, range1i, idx1), ActivePatternCaseUse (range2, range2i, idx2) -> - (idx1 = idx2) && (range1 = range2 || range1i = range2i) + (idx1 = idx2) && (Range.equals range1 range2 || Range.equals range1i range2i) | MethodUse minfo1, MethodUse minfo2 -> MethInfo.MethInfosUseIdenticalDefinitions minfo1 minfo2 || @@ -1411,10 +1415,10 @@ let ItemsAreEffectivelyEqual g orig other = | _ -> false | Item.ArgName (id1,_, _), Item.ArgName (id2,_, _) -> - (id1.idText = id2.idText && id1.idRange = id2.idRange) + (id1.idText = id2.idText && Range.equals id1.idRange id2.idRange) | (Item.ArgName (id,_, _), ValUse vref) | (ValUse vref, Item.ArgName (id, _, _)) -> - ((id.idRange = vref.DefinitionRange || id.idRange = vref.SigRange) && id.idText = vref.DisplayName) + ((Range.equals id.idRange vref.DefinitionRange || Range.equals id.idRange vref.SigRange) && id.idText = vref.DisplayName) | Item.AnonRecdField(anon1, _, i1, _), Item.AnonRecdField(anon2, _, i2, _) -> Tastops.anonInfoEquiv anon1 anon2 && i1 = i2 @@ -1530,7 +1534,7 @@ type TcResultsSinkImpl(g, ?sourceText: ISourceText) = new System.Collections.Generic.HashSet ( { new IEqualityComparer with member __.GetHashCode ((m, _)) = hash m - member __.Equals ((m1, item1), (m2, item2)) = m1 = m2 && ItemsAreEffectivelyEqual g item1 item2 } ) + member __.Equals ((m1, item1), (m2, item2)) = Range.equals m1 m2 && ItemsAreEffectivelyEqual g item1 item2 } ) let capturedMethodGroupResolutions = ResizeArray<_>() let capturedOpenDeclarations = ResizeArray() @@ -1576,8 +1580,8 @@ type TcResultsSinkImpl(g, ?sourceText: ISourceText) = // for the same identifier at the same location. if allowedRange m then if replace then - capturedNameResolutions.RemoveAll(fun cnr -> cnr.Range = m) |> ignore - capturedMethodGroupResolutions.RemoveAll(fun cnr -> cnr.Range = m) |> ignore + capturedNameResolutions.RemoveAll(fun cnr -> Range.equals cnr.Range m) |> ignore + capturedMethodGroupResolutions.RemoveAll(fun cnr -> Range.equals cnr.Range m) |> ignore else let alreadyDone = match item with @@ -1841,7 +1845,7 @@ let rec ResolveLongIndentAsModuleOrNamespace sink atMostOne amap m first fullyQu let mutable moduleNotFoundErrorCache = None let moduleNotFound (modref: ModuleOrNamespaceRef) (mty:ModuleOrNamespaceType) (id:Ident) depth = match moduleNotFoundErrorCache with - | Some (oldId, error) when oldId = id.idRange -> error + | Some (oldId, error) when Range.equals oldId id.idRange -> error | _ -> let suggestNames() = mty.ModulesAndNamespacesByDemangledName diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index 3b9c9e07647..9fc36fab465 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -671,22 +671,22 @@ let ShrinkContext env oldRange newRange = | ContextInfo.SequenceExpression _ -> env | ContextInfo.CollectionElement (b,m) -> - if m <> oldRange then env else + if not (Range.equals m oldRange) then env else { env with eContextInfo = ContextInfo.CollectionElement(b,newRange) } | ContextInfo.FollowingPatternMatchClause m -> - if m <> oldRange then env else + if not (Range.equals m oldRange) then env else { env with eContextInfo = ContextInfo.FollowingPatternMatchClause newRange } | ContextInfo.PatternMatchGuard m -> - if m <> oldRange then env else + if not (Range.equals m oldRange) then env else { env with eContextInfo = ContextInfo.PatternMatchGuard newRange } | ContextInfo.IfExpression m -> - if m <> oldRange then env else + if not (Range.equals m oldRange) then env else { env with eContextInfo = ContextInfo.IfExpression newRange } | ContextInfo.OmittedElseBranch m -> - if m <> oldRange then env else + if not (Range.equals m oldRange) then env else { env with eContextInfo = ContextInfo.OmittedElseBranch newRange } | ContextInfo.ElseBranchResult m -> - if m <> oldRange then env else + if not (Range.equals m oldRange) then env else { env with eContextInfo = ContextInfo.ElseBranchResult newRange } /// Optimized unification routine that avoids creating new inference diff --git a/src/fsharp/range.fs b/src/fsharp/range.fs index 001449fdc01..c208eee8e1e 100755 --- a/src/fsharp/range.fs +++ b/src/fsharp/range.fs @@ -5,7 +5,6 @@ module Microsoft.FSharp.Compiler.Range open System open System.IO -open System.Collections.Generic open System.Collections.Concurrent open Microsoft.FSharp.Core.Printf open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library @@ -195,14 +194,14 @@ type range(code1:int64, code2: int64) = override r.ToString() = sprintf "%s (%d,%d--%d,%d) IsSynthetic=%b" r.FileName r.StartLine r.StartColumn r.EndLine r.EndColumn r.IsSynthetic - static member op_Equality (x: range, y: range) = - x.Code1 = y.Code1 && x.Code2 = y.Code2 - let mkRange f b e = // remove relative parts from full path let normalizedFilePath = if Path.IsPathRooted f then try Path.GetFullPath f with _ -> f else f range (fileIndexOfFile normalizedFilePath, b, e) +let equals (r1: range) (r2: range) = + r1.Code1 = r2.Code1 && r1.Code2 = r2.Code2 + let mkFileIndexRange fi b e = range (fi, b, e) (* end representation, start derived ops *) diff --git a/src/fsharp/range.fsi b/src/fsharp/range.fsi index 5b3ea1e24d7..53deaca0e27 100755 --- a/src/fsharp/range.fsi +++ b/src/fsharp/range.fsi @@ -56,6 +56,8 @@ val mkFileIndexRange : FileIndex -> pos -> pos -> range /// This view hides the use of file indexes and just uses filenames val mkRange : string -> pos -> pos -> range +val equals : range -> range -> bool + val trimRangeToLine : range -> range /// not a total order, but enough to sort on ranges diff --git a/src/fsharp/service/ServiceNavigation.fs b/src/fsharp/service/ServiceNavigation.fs index 24d83f532bd..cd7f43e2036 100755 --- a/src/fsharp/service/ServiceNavigation.fs +++ b/src/fsharp/service/ServiceNavigation.fs @@ -71,7 +71,10 @@ type FSharpNavigationItems(declarations:FSharpNavigationTopLevelDeclaration[]) = member x.Declarations = declarations module NavigationImpl = - let unionRangesChecked r1 r2 = if r1 = range.Zero then r2 elif r2 = range.Zero then r1 else unionRanges r1 r2 + let unionRangesChecked r1 r2 = + if Microsoft.FSharp.Compiler.Range.equals r1 range.Zero then r2 + elif Microsoft.FSharp.Compiler.Range.equals r2 range.Zero then r1 + else unionRanges r1 r2 let rangeOfDecls2 f decls = match (decls |> List.map (f >> (fun (d:FSharpNavigationDeclarationItem) -> d.bodyRange))) with From f20326e9dd353547cc2860b2b47f628b5c70e381 Mon Sep 17 00:00:00 2001 From: Phillip Carter Date: Fri, 21 Dec 2018 14:39:37 -0800 Subject: [PATCH 4/4] Change the rest of the range equality comparisons to use range equality functions --- src/fsharp/CompileOps.fs | 32 +++++++++++++-------------- src/fsharp/ErrorLogger.fs | 2 +- src/fsharp/NameResolution.fs | 4 ++-- src/fsharp/PatternMatchCompilation.fs | 2 +- src/fsharp/TypeChecker.fs | 2 +- src/fsharp/fsc.fs | 2 +- src/fsharp/service/service.fs | 2 +- src/fsharp/symbols/SymbolHelpers.fs | 2 +- src/fsharp/symbols/Symbols.fs | 4 ++-- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 6ff3b33d554..08e74a252e2 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -646,16 +646,16 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = let t1, t2, _cxs = NicePrint.minimalStringsOfTwoTypes denv t1 t2 match contextInfo with - | ContextInfo.IfExpression range when range = m -> os.Append(FSComp.SR.ifExpression(t1, t2)) |> ignore - | ContextInfo.CollectionElement (isArray, range) when range = m -> + | ContextInfo.IfExpression range when Range.equals range m -> os.Append(FSComp.SR.ifExpression(t1, t2)) |> ignore + | ContextInfo.CollectionElement (isArray, range) when Range.equals range m -> if isArray then os.Append(FSComp.SR.arrayElementHasWrongType(t1, t2)) |> ignore else os.Append(FSComp.SR.listElementHasWrongType(t1, t2)) |> ignore - | ContextInfo.OmittedElseBranch range when range = m -> os.Append(FSComp.SR.missingElseBranch(t2)) |> ignore - | ContextInfo.ElseBranchResult range when range = m -> os.Append(FSComp.SR.elseBranchHasWrongType(t1, t2)) |> ignore - | ContextInfo.FollowingPatternMatchClause range when range = m -> os.Append(FSComp.SR.followingPatternMatchClauseHasWrongType(t1, t2)) |> ignore - | ContextInfo.PatternMatchGuard range when range = m -> os.Append(FSComp.SR.patternMatchGuardIsNotBool(t2)) |> ignore + | ContextInfo.OmittedElseBranch range when Range.equals range m -> os.Append(FSComp.SR.missingElseBranch(t2)) |> ignore + | ContextInfo.ElseBranchResult range when Range.equals range m -> os.Append(FSComp.SR.elseBranchHasWrongType(t1, t2)) |> ignore + | ContextInfo.FollowingPatternMatchClause range when Range.equals range m -> os.Append(FSComp.SR.followingPatternMatchClauseHasWrongType(t1, t2)) |> ignore + | ContextInfo.PatternMatchGuard range when Range.equals range m -> os.Append(FSComp.SR.patternMatchGuardIsNotBool(t2)) |> ignore | _ -> os.Append(ConstraintSolverTypesNotInEqualityRelation2E().Format t1 t2) |> ignore if m.StartLine <> m2.StartLine then os.Append(SeeAlsoE().Format (stringOfRange m)) |> ignore @@ -683,16 +683,16 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = && typeEquiv g t2 t2' -> let t1, t2, tpcs = NicePrint.minimalStringsOfTwoTypes denv t1 t2 match contextInfo with - | ContextInfo.IfExpression range when range = m -> os.Append(FSComp.SR.ifExpression(t1, t2)) |> ignore - | ContextInfo.CollectionElement (isArray, range) when range = m -> + | ContextInfo.IfExpression range when Range.equals range m -> os.Append(FSComp.SR.ifExpression(t1, t2)) |> ignore + | ContextInfo.CollectionElement (isArray, range) when Range.equals range m -> if isArray then os.Append(FSComp.SR.arrayElementHasWrongType(t1, t2)) |> ignore else os.Append(FSComp.SR.listElementHasWrongType(t1, t2)) |> ignore - | ContextInfo.OmittedElseBranch range when range = m -> os.Append(FSComp.SR.missingElseBranch(t2)) |> ignore - | ContextInfo.ElseBranchResult range when range = m -> os.Append(FSComp.SR.elseBranchHasWrongType(t1, t2)) |> ignore - | ContextInfo.FollowingPatternMatchClause range when range = m -> os.Append(FSComp.SR.followingPatternMatchClauseHasWrongType(t1, t2)) |> ignore - | ContextInfo.PatternMatchGuard range when range = m -> os.Append(FSComp.SR.patternMatchGuardIsNotBool(t2)) |> ignore + | ContextInfo.OmittedElseBranch range when Range.equals range m -> os.Append(FSComp.SR.missingElseBranch(t2)) |> ignore + | ContextInfo.ElseBranchResult range when Range.equals range m -> os.Append(FSComp.SR.elseBranchHasWrongType(t1, t2)) |> ignore + | ContextInfo.FollowingPatternMatchClause range when Range.equals range m -> os.Append(FSComp.SR.followingPatternMatchClauseHasWrongType(t1, t2)) |> ignore + | ContextInfo.PatternMatchGuard range when Range.equals range m -> os.Append(FSComp.SR.patternMatchGuardIsNotBool(t2)) |> ignore | ContextInfo.TupleInRecordFields -> os.Append(ErrorFromAddingTypeEquation1E().Format t2 t1 tpcs) |> ignore os.Append(System.Environment.NewLine + FSComp.SR.commaInsteadOfSemicolonInRecord()) |> ignore @@ -1640,7 +1640,7 @@ type Diagnostic = /// returns sequence that contains Diagnostic for the given error + Diagnostic for all related errors let CollectDiagnostic (implicitIncludeDir, showFullPaths, flattenErrors, errorStyle, isError, err:PhasedDiagnostic) = let outputWhere (showFullPaths, errorStyle) m : DiagnosticLocation = - if m = rangeStartup || m = rangeCmdArgs then + if Range.equals m rangeStartup || Range.equals m rangeCmdArgs then { Range = m; TextRepresentation = ""; IsEmpty = true; File = "" } else let file = m.FileName @@ -1675,7 +1675,7 @@ let CollectDiagnostic (implicitIncludeDir, showFullPaths, flattenErrors, errorSt | ErrorStyle.VSErrors -> // Show prefix only for real files. Otherwise, we just want a truncated error like: // parse error FS0031 : blah blah - if m<>range0 && m<>rangeStartup && m<>rangeCmdArgs then + if not (Range.equals m range0) && not (Range.equals m rangeStartup) && not (Range.equals m rangeCmdArgs) then let file = file.Replace("/", "\\") let m = mkRange m.FileName (mkPos m.StartLine (m.StartColumn + 1)) (mkPos m.EndLine (m.EndColumn + 1) ) sprintf "%s(%d,%d,%d,%d): " file m.StartLine m.StartColumn m.EndLine m.EndColumn, m, file @@ -2760,7 +2760,7 @@ type TcConfig private (data : TcConfigBuilder, validate:bool) = r, Some(filename) else // If the file doesn't exist, let reference resolution logic report the error later... - defaultCoreLibraryReference, if r.Range =rangeStartup then Some(filename) else None + defaultCoreLibraryReference, if Range.equals r.Range rangeStartup then Some(filename) else None match data.referencedDLLs |> List.filter (fun assemblyReference -> assemblyReference.SimpleAssemblyNameIs libraryName) with | [r] -> nameOfDll r | [] -> @@ -5222,7 +5222,7 @@ module private ScriptPreprocessClosure = match GetRangeOfDiagnostic exn with | Some m -> // Return true if the error was *not* from a #load-ed file. - let isArgParameterWhileNotEditing = (codeContext <> CodeContext.Editing) && (m = range0 || m = rangeStartup || m = rangeCmdArgs) + let isArgParameterWhileNotEditing = (codeContext <> CodeContext.Editing) && (Range.equals m range0 || Range.equals m rangeStartup || Range.equals m rangeCmdArgs) let isThisFileName = (0 = String.Compare(rootFilename, m.FileName, StringComparison.OrdinalIgnoreCase)) isArgParameterWhileNotEditing || isThisFileName | None -> true diff --git a/src/fsharp/ErrorLogger.fs b/src/fsharp/ErrorLogger.fs index 41be3768ed2..9a8defde765 100755 --- a/src/fsharp/ErrorLogger.fs +++ b/src/fsharp/ErrorLogger.fs @@ -125,7 +125,7 @@ let inline protectAssemblyExplorationNoReraise dflt1 dflt2 f = // Attach a range if this is a range dual exception. let rec AttachRange m (exn:exn) = - if m = range0 then exn + if Range.equals m range0 then exn else match exn with // Strip TargetInvocationException wrappers diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index e2f9874c10f..09ab9e1945b 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -2597,7 +2597,7 @@ let rec ResolveExprLongIdentPrim sink (ncenv:NameResolver) first fullyQualified } |> HashSet match innerSearch with - | Exception (UndefinedName(0,_,id1,suggestionsF)) when id.idRange = id1.idRange -> + | Exception (UndefinedName(0,_,id1,suggestionsF)) when Range.equals id.idRange id1.idRange -> let mergeSuggestions() = let res = suggestEverythingInScope() res.UnionWith(suggestionsF()) @@ -3285,7 +3285,7 @@ let ResolveLongIdentAsExprAndComputeRange (sink:TcResultsSink) (ncenv:NameResolv match lid with | [] | [_] -> false | head :: ids -> - ids |> List.forall (fun id -> id.idRange = head.idRange) + ids |> List.forall (fun id -> Range.equals id.idRange head.idRange) let callSink (refinedItem, tpinst) = if not isFakeIdents then diff --git a/src/fsharp/PatternMatchCompilation.fs b/src/fsharp/PatternMatchCompilation.fs index 625b23a70d0..96463de480e 100644 --- a/src/fsharp/PatternMatchCompilation.fs +++ b/src/fsharp/PatternMatchCompilation.fs @@ -1331,7 +1331,7 @@ let rec CompilePattern g denv amap exprm matchm warnOnUnused actionOnFailure (o // If the remainder of the match boiled away to nothing interesting. // We measure this simply by seeing if the range of the resulting expression is identical to matchm. let spTarget = - if expr.Range = matchm then SuppressSequencePointAtTarget + if Range.equals expr.Range matchm then SuppressSequencePointAtTarget else SequencePointAtTarget // Make the clause that represents the remaining cases of the pattern match diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index 9fc36fab465..0651a6407e4 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -11572,7 +11572,7 @@ and AnalyzeAndMakeAndPublishRecursiveValue overridesOK isGeneratedEventVal cenv // Suppress hover tip for "get" and "set" at property definitions, where toolId <> bindingId match toolIdOpt with - | Some tid when not tid.idRange.IsSynthetic && tid.idRange <> bindingId.idRange -> + | Some tid when not tid.idRange.IsSynthetic && not (Range.equals tid.idRange bindingId.idRange) -> let item = Item.Value (mkLocalValRef vspec) CallNameResolutionSink cenv.tcSink (tid.idRange, env.NameEnv, item, item, emptyTyparInst, ItemOccurence.RelatedText, env.DisplayEnv, env.eAccessRights) | _ -> () diff --git a/src/fsharp/fsc.fs b/src/fsharp/fsc.fs index b19c3b280ab..fa3831018ed 100644 --- a/src/fsharp/fsc.fs +++ b/src/fsharp/fsc.fs @@ -205,7 +205,7 @@ let AdjustForScriptCompile(ctok, tcConfigB:TcConfigBuilder, commandLineSourceFil let closure = LoadClosure.ComputeClosureOfScriptFiles(ctok, tcConfig, [filename, rangeStartup], CodeContext.Compilation, lexResourceManager=lexResourceManager) // Record the references from the analysis of the script. The full resolutions are recorded as the corresponding #I paths used to resolve them // are local to the scripts and not added to the tcConfigB (they are added to localized clones of the tcConfigB). - let references = closure.References |> List.collect snd |> List.filter (fun r->r.originalReference.Range<>range0 && r.originalReference.Range<>rangeStartup) + let references = closure.References |> List.collect snd |> List.filter (fun r -> not (Range.equals r.originalReference.Range range0) && not (Range.equals r.originalReference.Range rangeStartup)) references |> List.iter (fun r-> tcConfigB.AddReferencedAssemblyByPath(r.originalReference.Range, r.resolvedPath)) closure.NoWarns |> List.collect (fun (n, ms) -> ms|>List.map(fun m->m, n)) |> List.iter (fun (x,m) -> tcConfigB.TurnWarningOff(x, m)) closure.SourceFiles |> List.map fst |> List.iter AddIfNotPresent diff --git a/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index 7a0e9f2f69d..f46ad3629d1 100644 --- a/src/fsharp/service/service.fs +++ b/src/fsharp/service/service.fs @@ -1030,7 +1030,7 @@ type TypeCheckInfo let pos = mkPos line col let isPosMatch(pos, ar:AssemblyReference) : bool = let isRangeMatch = (Range.rangeContainsPos ar.Range pos) - let isNotSpecialRange = (ar.Range <> rangeStartup) && (ar.Range <> range0) && (ar.Range <> rangeCmdArgs) + let isNotSpecialRange = not (Range.equals ar.Range rangeStartup) && not (Range.equals ar.Range range0) && not (Range.equals ar.Range rangeCmdArgs) let isMatch = isRangeMatch && isNotSpecialRange isMatch diff --git a/src/fsharp/symbols/SymbolHelpers.fs b/src/fsharp/symbols/SymbolHelpers.fs index f4fb7c02383..e4a971879f3 100644 --- a/src/fsharp/symbols/SymbolHelpers.fs +++ b/src/fsharp/symbols/SymbolHelpers.fs @@ -742,7 +742,7 @@ module internal SymbolHelpers = | Item.TypeVar (nm1, tp1), Item.TypeVar (nm2, tp2) -> (nm1 = nm2) && typarRefEq tp1 tp2 | Item.ModuleOrNamespaces(modref1 :: _), Item.ModuleOrNamespaces(modref2 :: _) -> fullDisplayTextOfModRef modref1 = fullDisplayTextOfModRef modref2 - | Item.SetterArg(id1, _), Item.SetterArg(id2, _) -> (id1.idRange, id1.idText) = (id2.idRange, id2.idText) + | Item.SetterArg(id1, _), Item.SetterArg(id2, _) -> Range.equals id1.idRange id2.idRange && id1.idText = id2.idText | Item.MethodGroup(_, meths1, _), Item.MethodGroup(_, meths2, _) -> Seq.zip meths1 meths2 |> Seq.forall (fun (minfo1, minfo2) -> MethInfo.MethInfosUseIdenticalDefinitions minfo1 minfo2) diff --git a/src/fsharp/symbols/Symbols.fs b/src/fsharp/symbols/Symbols.fs index fa3fcccfc82..c2b2b6910ae 100644 --- a/src/fsharp/symbols/Symbols.fs +++ b/src/fsharp/symbols/Symbols.fs @@ -2307,7 +2307,7 @@ and FSharpStaticParameter(cenv, sp: Tainted< ExtensionTyping.ProvidedParameterIn override x.Equals(other: obj) = box x === other || match other with - | :? FSharpStaticParameter as p -> x.Name = p.Name && x.DeclarationLocation = p.DeclarationLocation + | :? FSharpStaticParameter as p -> x.Name = p.Name && Range.equals x.DeclarationLocation p.DeclarationLocation | _ -> false override x.GetHashCode() = hash x.Name @@ -2352,7 +2352,7 @@ and FSharpParameter(cenv, paramTy:TType, topArgInfo:ArgReprInfo, mOpt, isParamAr override x.Equals(other: obj) = box x === other || match other with - | :? FSharpParameter as p -> x.Name = p.Name && x.DeclarationLocation = p.DeclarationLocation + | :? FSharpParameter as p -> x.Name = p.Name && Range.equals x.DeclarationLocation p.DeclarationLocation | _ -> false override x.GetHashCode() = hash (box topArgInfo)