Skip to content

Commit

Permalink
Overload resolution error messages: things display like I want in fsi…
Browse files Browse the repository at this point in the history
…, almost like I want in VS2019, this is for the simple non generic method overload case.

I want to check if user experience changes wrt dotnet#2503 and put some time to add tests.
  • Loading branch information
smoothdeveloper committed Feb 15, 2020
1 parent f1eadef commit 9eb633a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/fsharp/CompileOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,10 @@ let OutputPhasedErrorR (os: StringBuilder) (err: PhasedDiagnostic) (canSuggestNa
#endif

| UnresolvedOverloading(denv, mtext, overloads, m) ->
os.AppendLine mtext |> ignore
os.Append mtext |> ignore
overloads
|> List.map (fun e -> e.overload.OverloadMethodInfo denv m |> FSComp.SR.formatDashItem)
|> List.iter (os.AppendLine >> ignore)
|> List.iter (os.Append >> ignore)

| UnresolvedConversionOperator(denv, fromTy, toTy, _) ->
let t1, t2, _tpcs = NicePrint.minimalStringsOfTwoTypes denv fromTy toTy
Expand Down
13 changes: 6 additions & 7 deletions src/fsharp/ConstraintSolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2542,24 +2542,23 @@ and ResolveOverloading
function | (Some argName), typeLayout -> sprintf "(%s) : %s" argName (Display.layout_to_string formatOptions typeLayout)
| _, typeLayout -> (Display.layout_to_string formatOptions typeLayout)

let nl = System.Environment.NewLine
let argsMessage =
match callerArgs.LayoutArgumentTypes denv with
| [] -> System.String.Empty
| [item] -> Environment.NewLine + (item |> getArgType |> FSComp.SR.csNoOverloadsFoundArgumentsPrefixSingular)
| [item] -> nl + (item |> getArgType |> FSComp.SR.csNoOverloadsFoundArgumentsPrefixSingular)
| items ->
let args =
items
|> List.map (getArgType >> FSComp.SR.formatDashItem)
|> List.toArray
|> String.concat Environment.NewLine
|> String.concat nl

Environment.NewLine
+ Environment.NewLine
nl + nl
+ (FSComp.SR.csNoOverloadsFoundArgumentsPrefixPlural())
+ Environment.NewLine
+ nl
+ args
+ Environment.NewLine
+ Environment.NewLine
+ nl + nl


//printfn "%A" argsMessage
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ csNoOverloadsFoundArgumentsPrefixSingular,"Argument given: %s"
csNoOverloadsFoundArgumentsPrefixPlural,"Arguments given:"
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."
csCandidates,"Candidates: %s"
csSeeAvailableOverloads,"The available overloads are shown below."
csSeeAvailableOverloads,"Available overloads:"
512,parsDoCannotHaveVisibilityDeclarations,"Accessibility modifiers are not permitted on 'do' bindings, but '%s' was given."
513,parsEofInHashIf,"End of file in #if section begun at or after here"
514,parsEofInString,"End of file in string begun at or before here"
Expand Down

0 comments on commit 9eb633a

Please sign in to comment.