Skip to content

Commit

Permalink
trying to check what kind of things break loose when I change this
Browse files Browse the repository at this point in the history
I'm trying to identify why we get `(CalledMeth<Expr> * exn list)`, I'm making a cartesian product through getMethodSlotsAndErrors for now, trying to figure out if we can get other than 0 or 1 exception in the list for a given method slot.

I may revert that one if it doesn't make sense make from a reviewer standpoint and/or breaks fsharpqa tests surounding overload resolution error messages.
  • Loading branch information
smoothdeveloper committed Apr 24, 2019
1 parent b15c2e4 commit 50a3a33
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
53 changes: 34 additions & 19 deletions src/fsharp/ConstraintSolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ with
/// Cases for overload resolution failure that exists in the implementation of the compiler.
type OverloadResolutionFailure =
| NoOverloadsFound of methodName: string * candidates: OverloadInformation list
| PossibleCandidates of methodName: string * methodNames: string list // methodNames may be different (with operators?), this is refactored from original logic to assemble overload failure message
| PossibleCandidates of methodName: string * candidates: OverloadInformation list // methodNames may be different (with operators?), this is refactored from original logic to assemble overload failure message

exception ConstraintSolverTupleDiffLengths of displayEnv: DisplayEnv * TType list * TType list * range * range
exception ConstraintSolverInfiniteTypes of displayEnv: DisplayEnv * contextInfo: ContextInfo * TType * TType * range * range
Expand Down Expand Up @@ -2407,7 +2407,13 @@ and ResolveOverloading
let msg = FSComp.SR.csMethodIsOverloaded methodName
match methodNames with
| [] -> msg
| names -> sprintf "%s %s" msg (FSComp.SR.csCandidates (String.concat ", " names))
| names ->
names
|> List.map (fun overload -> NicePrint.stringOfMethInfo amap m denv overload.methodSlot.Method)
|> List.sort
|> String.concat ", "
|> FSComp.SR.csCandidates
|> sprintf "%s %s" msg

let overloads =
overloadResolutionFailure
Expand Down Expand Up @@ -2439,7 +2445,7 @@ and ResolveOverloading
reqdRetTyOpt
calledMeth) with
| OkResult _ -> None
| ErrorResult(_, exn) -> Some {methodSlot = calledMeth; amap = amap; error = exn })
| ErrorResult(_exns, exn) -> Some {methodSlot = calledMeth; amap = amap; error = exn })

None, ErrorD (failOverloading (NoOverloadsFound (methodName, errors))), NoTrace

Expand Down Expand Up @@ -2581,23 +2587,32 @@ and ResolveOverloading
match bestMethods with
| [(calledMeth, warns, t)] -> Some calledMeth, OkResult (warns, ()), WithTrace t
| bestMethods ->
let methodNames =
let methods =
// use the most precise set
// - if after filtering bestMethods still contains something - use it
// - otherwise use applicableMeths or initial set of candidate methods
match bestMethods with
| [] ->
match applicableMeths with
| [] -> candidates
| m -> m |> List.map (fun (x, _, _) -> x)
| m -> m |> List.map (fun (x, _, _) -> x)

methods
|> List.map (fun cmeth -> NicePrint.stringOfMethInfo amap m denv cmeth.Method)
|> List.sort

None, ErrorD (failOverloading (PossibleCandidates(methodName, methodNames))), NoTrace
//let methodNames =
let methods =
// use the most precise set
// - if after filtering bestMethods still contains something - use it
// - otherwise use applicableMeths or initial set of candidate methods

let getMethodSlotsAndErrors =
function | methodSlot, [] -> List.singleton {methodSlot = methodSlot; error = Unchecked.defaultof<exn>; amap = amap}
| methodSlot, [error] -> List.singleton {methodSlot = methodSlot; error = error; amap = amap}
| methodSlot, errors -> errors |> List.map (fun error -> {methodSlot = methodSlot; error = error; amap = amap})
// not totally sure about what's going on with last case, so making cartesian product in case we have several exceptions

match bestMethods with
| [] ->
match applicableMeths with
| [] -> candidates |> List.map (fun methodSlot -> getMethodSlotsAndErrors (methodSlot, []))
| m -> m |> List.map (fun (methodSlot, errors, _) -> getMethodSlotsAndErrors (methodSlot,errors))
| m -> m |> List.map (fun (methodSlot, errors, _) -> getMethodSlotsAndErrors (methodSlot,errors))


let methods = List.concat methods
//|> List.map (fun cmeth -> NicePrint.stringOfMethInfo amap m denv cmeth.Method)
//|> List.sort

None, ErrorD (failOverloading (PossibleCandidates(methodName, methods))), NoTrace

// If we've got a candidate solution: make the final checks - no undo here!
// Allow subsumption on arguments. Include the return type.
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/ConstraintSolver.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ with
/// Cases for overload resolution failure that exists in the implementation of the compiler.
type OverloadResolutionFailure =
| NoOverloadsFound of methodName: string * candidates: OverloadInformation list
| PossibleCandidates of methodName: string * methodNames: string list // methodNames may be different (with operators?), this is refactored from original logic to assemble overload failure message
| PossibleCandidates of methodName: string * candidates: OverloadInformation list // methodNames may be different (with operators?), this is refactored from original logic to assemble overload failure message

exception ConstraintSolverTupleDiffLengths of displayEnv: DisplayEnv * TType list * TType list * range * range
exception ConstraintSolverInfiniteTypes of displayEnv: DisplayEnv * contextInfo: ContextInfo * TType * TType * range * range
Expand Down

0 comments on commit 50a3a33

Please sign in to comment.