Skip to content
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
44 changes: 25 additions & 19 deletions src/fsharp/CompileOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ','
Expand Down Expand Up @@ -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
| [] ->
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -5216,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
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/ErrorLogger.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 19 additions & 15 deletions src/fsharp/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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) =
Expand All @@ -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) =
Expand All @@ -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)
Expand All @@ -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 ||
Expand All @@ -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

Expand Down Expand Up @@ -1530,7 +1534,7 @@ type TcResultsSinkImpl(g, ?sourceText: ISourceText) =
new System.Collections.Generic.HashSet<range * Item>
( { new IEqualityComparer<range * Item> 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<OpenDeclaration>()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2593,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())
Expand Down Expand Up @@ -3281,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
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/PatternMatchCompilation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
| _ -> ()
Expand Down
Loading