Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
1e00e9d
migrate (as a separate copy) fsharpqa tests that are going to be impa…
smoothdeveloper Apr 30, 2019
0f01896
update the .bsl files
smoothdeveloper Apr 30, 2019
8b0c809
remove comments that are handled by baseline files, update baseline f…
smoothdeveloper Apr 30, 2019
15823c0
remove the migrated tests from fsharpqa tests
smoothdeveloper Apr 30, 2019
7d6b203
need to be more careful when migrating those
smoothdeveloper Apr 30, 2019
d4c378e
testing if running the test with .fs instead of .fsx makes them work …
smoothdeveloper Apr 30, 2019
efd70e3
exclude migrated fsharpqa from dotnet core run
smoothdeveloper Apr 30, 2019
b343d33
sample test in fsharpqa (can't run locally for now)
smoothdeveloper Apr 20, 2019
05b6055
trying to make it green now.
smoothdeveloper Apr 21, 2019
2a4ccdc
checking if this path is covered by a test, trying to identify how to…
smoothdeveloper Apr 21, 2019
3eab5f2
* [MethodCalls.fs] Defining CallerArgs<'T> in, this replaces passing …
smoothdeveloper Apr 22, 2019
d59606d
bit of refactoring of error message building logic during failed over…
smoothdeveloper Apr 23, 2019
bd2932d
(buildfix) harmonizing .fsi/.fs right before commit doesn't always wo…
smoothdeveloper Apr 23, 2019
723eb07
trying to check what kind of things break loose when I change this
smoothdeveloper Apr 24, 2019
fdb48e1
(minor) [ConstraintSolver.fs] revert space mishapps to reduce diff, p…
smoothdeveloper Apr 24, 2019
2e74e08
toward displaying the argument names properly (may fail some fsharpqa…
smoothdeveloper Apr 24, 2019
f41a791
missing Resharper's Ctrl+Alt+V "introduce variable" refactoring @audu…
smoothdeveloper Apr 24, 2019
9d76863
pretty print unresolved overloads without all the type submsumption p…
smoothdeveloper Apr 25, 2019
7437b53
Overload resolution error messages: things display like I want in fsi…
smoothdeveloper Apr 25, 2019
ed466df
adjust message for candidates overload
smoothdeveloper Apr 26, 2019
3b1fe30
Refactoring around `CallerArg`
smoothdeveloper Apr 27, 2019
b2a5946
Hijack the split phase for UnresolvedOverloading, remove the match on…
smoothdeveloper Apr 29, 2019
950d64f
updating existing failing baseline files that looks correct to me
smoothdeveloper Apr 29, 2019
c1d9619
quickfix for update.base.line.with.actuals.fsx so that it skips missi…
smoothdeveloper Apr 29, 2019
797a31d
(minor) minimize diff, typos, comments
smoothdeveloper Apr 30, 2019
1df43c1
fix vsintegration tests affected by overload error message changes
smoothdeveloper Apr 30, 2019
5a3f77e
merge issue unused variable warning
smoothdeveloper Apr 30, 2019
1e26d72
update the 12 fsharpqa migrated baseline with new error messages
smoothdeveloper Apr 30, 2019
dc40085
(minor) baseline update script
smoothdeveloper Apr 30, 2019
ededba9
move System.Convert.ToString and System.Threading.Tasks.Task.Run test…
smoothdeveloper Apr 30, 2019
4118790
* moving 3 fsharpqa tests to new test suite
smoothdeveloper May 2, 2019
2d2ee31
consolidate all string building logic in CompileOps.fs, fix remaining…
smoothdeveloper May 2, 2019
70ebbcd
update base lines
smoothdeveloper May 2, 2019
3882a83
remove the migrated tests from fsharpqa
smoothdeveloper May 2, 2019
b86d5b9
fix vstest error message
smoothdeveloper May 2, 2019
062f1ac
fix env.lst, removed wrong one...
smoothdeveloper May 2, 2019
d8503be
update baselines of remaining tests
smoothdeveloper May 2, 2019
b90c37d
adding one simple test with many overloads
smoothdeveloper May 2, 2019
3749dc7
appropriate /// comments on `CalledMeth` constructor arguments
smoothdeveloper May 2, 2019
1b2a7f5
minimize diff / formatting
smoothdeveloper May 2, 2019
68792c5
trim unused code
smoothdeveloper May 2, 2019
56ab693
add simple test, one message is interesting, mentioning parameter cou…
smoothdeveloper May 3, 2019
5d23a08
comment flaky test for now
smoothdeveloper May 3, 2019
dd376f3
code review on the `coerceExpr` function from @tihan, we can discard …
smoothdeveloper May 8, 2019
d90439a
code formatting remarks on ConstraintSolver.fs/fsi
smoothdeveloper May 14, 2019
e138e94
`CallerArg`: use plain constructor rather than functions
smoothdeveloper May 14, 2019
ee8af88
(minor) formatting
smoothdeveloper May 14, 2019
3ecd438
format known argument type / updating .bsl
smoothdeveloper May 16, 2019
b58bb44
update missing baseline
smoothdeveloper May 16, 2019
b6c628e
update missing baselines
smoothdeveloper May 16, 2019
3acee0f
update missing baseline
smoothdeveloper May 16, 2019
d6b1198
minor: make TTrait better in debugger display
smoothdeveloper Aug 24, 2019
8c01c6a
[wip] pass TraitConstraintInfo around failed overload resolution erro…
smoothdeveloper Aug 24, 2019
5326132
minimize diff
smoothdeveloper Aug 27, 2019
06d622f
fix missing calls to CallerArgs.make that should be a plain record in…
smoothdeveloper Aug 27, 2019
4ff46a0
signature file mismatch
smoothdeveloper Aug 27, 2019
fec7374
removing duplicate in fscomp.txt
smoothdeveloper Dec 27, 2019
47f2217
surfacing initial bits of TraitConstraintInfo, roughly for now
smoothdeveloper Dec 27, 2019
650a25e
formatting types of known argument in one go, the formatting is still…
smoothdeveloper Jan 12, 2020
b1067f4
rework of overload failure message to prettify *ALL* types in a singl…
smoothdeveloper Jan 15, 2020
2a02797
fixup the tests and add two tests
smoothdeveloper Jan 15, 2020
31302fb
updating baselines that got tighter.
smoothdeveloper Jan 16, 2020
e5d87db
simplify handling of TraitConstraintInfo
smoothdeveloper Jan 16, 2020
1c7c5dd
naming couple of fields and turning a property to a methods as it tri…
smoothdeveloper Jan 17, 2020
82b8585
comments in the assembling of overload resolution error message
smoothdeveloper Jan 17, 2020
fdabb8d
Add information about which argument doesn't match
smoothdeveloper Jan 19, 2020
1ce83b7
minor updates to testguide and devguide
smoothdeveloper Jan 19, 2020
94fe319
fix PrimitiveConstraints.``Invalid object constructor`` test
smoothdeveloper Jan 19, 2020
88883f2
fix(?) salsa tests
smoothdeveloper Jan 19, 2020
0ef5c5a
minimize diff
smoothdeveloper Jan 19, 2020
94fc0aa
put back tests under !FSHARP_SUITE_DRIVES_CORECLR_TESTS
smoothdeveloper Jan 19, 2020
16204ef
missing updated message
smoothdeveloper Jan 19, 2020
2b81768
minor adjustments to TESTGUIDE.md
smoothdeveloper Jan 19, 2020
f5b33dd
return type was missing prettifying in prettyLayoutsOfUnresolvedOverl…
smoothdeveloper Jan 19, 2020
dafdf5c
address code review nits / minimize diff / add comment on PrettifyDis…
smoothdeveloper Jan 22, 2020
a51e852
minimize diff
smoothdeveloper Jan 22, 2020
f2bb3b8
proposed work around the flaky error message until https://github.com…
smoothdeveloper Jan 22, 2020
46bb5d5
fixing baselines of new tests from master
smoothdeveloper Jan 22, 2020
e50cfba
sisyphus round of baseline update
smoothdeveloper Jan 22, 2020
9246b82
removing type which isn't in use and popped back up after rebase
smoothdeveloper Jan 22, 2020
d5edf2c
minimize diff
smoothdeveloper Jan 23, 2020
69bcd70
tidy inconsistent tuple literal
smoothdeveloper Jan 23, 2020
fd48d39
* removing TTrait properties that end up not being used
smoothdeveloper Jan 23, 2020
27c0806
minimize diff
smoothdeveloper Jan 23, 2020
000d414
minimize diff
smoothdeveloper Jan 23, 2020
faf86ad
minimize diff
smoothdeveloper Jan 23, 2020
b968b15
link to usage example in same file
smoothdeveloper Jan 24, 2020
f302e63
revert converting CallerArg single cased DU into Record
smoothdeveloper Jan 29, 2020
546b8ec
minimize diff
smoothdeveloper Jan 29, 2020
bddf474
minimize diff
smoothdeveloper Jan 29, 2020
6c2aa58
minimize diff
smoothdeveloper Jan 29, 2020
26fab46
minimize diff
smoothdeveloper Jan 29, 2020
50c8414
minimize diff
smoothdeveloper Jan 29, 2020
bba6a44
Update Makefile
smoothdeveloper Feb 15, 2020
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
Prev Previous commit
Next Next commit
rework of overload failure message to prettify *ALL* types in a singl…
…e go, not only argument types, but return types and known generic argument types (this info was never displayed originally but is useful for scenario similar to FSharpPlus implementation)

added `PrettifyDiscriminantAndTypePairs` in TastOps, this allow to weave extra information with the complete list of types, to help reconstituting the several types from their origin (in the usage spot: argument types, return type, generic parameter types)
  • Loading branch information
smoothdeveloper committed Jan 31, 2020
commit b1067f4f6a7848979211182dd8b00ae8d9cc2d81
136 changes: 57 additions & 79 deletions src/fsharp/CompileOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -766,106 +766,84 @@ let OutputPhasedErrorR (os: StringBuilder) (err: PhasedDiagnostic) (canSuggestNa

| UnresolvedOverloading(denv, callerArgs, failure, m) ->
let nl = System.Environment.NewLine
let argsMessage =
let prefix = nl + nl
let suffix = nl + nl
let cx =
match failure with
| NoOverloadsFound (cx=cx)
| PossibleCandidates (cx=cx) -> cx

let retTy =
cx
|> Option.map (fun cx -> cx.ReturnType)
|> Option.flatten
|> Option.defaultValue (TType.TType_var (Typar.NewUnlinked()))

let genericParameters =
cx
|> Option.map (fun cx -> cx.ArgTys)
|> Option.defaultValue List.empty

let argsMessage, returnType, genericParameters =
let argRepr =
callerArgs.ArgumentNamesAndTypes
|> List.map (fun (name,tTy) -> tTy, {ArgReprInfo.Name = name |> Option.map (fun name -> Ident(name, range.Zero)); ArgReprInfo.Attribs = []})
let argsL,retTyL,genParamTysL = NicePrint.prettyLayoutsOfUnresolvedOverloading denv argRepr retTy genericParameters
match callerArgs.ArgumentNamesAndTypes with
| [] -> nl + nl
| items ->
// more than one argument, need to lay them out in a single pass

//let cxs = []
let argsL =
NicePrint.prettyLayoutOfUnresolvedMethodCallArguments
denv
[]
(items |> List.map (fun (name,tTy) -> tTy, {ArgReprInfo.Name = name |> Option.map (fun name -> Ident(name, range.Zero)); Attribs = []}))
//cxs
let args = argsL |> List.map Layout.showL |> String.concat " "
(*let args =
items
|> List.map displayArgType
|> String.concat " * "
*)
| [] -> None, Layout.showL retTyL, Layout.showL genParamTysL
| items ->
let args = Layout.showL argsL
let prefixMessage =
match items with
| [_] -> FSComp.SR.csNoOverloadsFoundArgumentsPrefixSingular
| _ -> FSComp.SR.csNoOverloadsFoundArgumentsPrefixPlural
prefix + (prefixMessage args) + suffix
Some (prefixMessage args)
, Layout.showL retTyL
, Layout.showL genParamTysL

let knownReturnType (cx: TraitConstraintInfo option) =
let knownReturnType =
match cx with
| None -> String.Empty
| None -> None
| Some cx ->
let prefix = nl + nl
let suffix = nl + nl
match cx.ReturnType with
| None -> String.Empty
| Some t ->
prefix + (NicePrint.prettyStringOfTy denv t |> FSComp.SR.csNoOverloadsFoundReturnType) + suffix
| None -> None
| Some _ -> Some (FSComp.SR.csNoOverloadsFoundReturnType returnType)

let genericParametersMessage (cx: TraitConstraintInfo option) =
let genericParametersMessage =
match cx with
| None -> String.Empty
| None -> None
| Some cx ->
let prefix = nl + nl
let suffix = nl + nl

match cx.ArgTys with
| [] -> nl + nl
| [item] -> prefix + (item |> NicePrint.prettyStringOfTy denv |> FSComp.SR.csNoOverloadsFoundTypeParametersPrefixSingular) + suffix
| items ->
let args =
items
|> List.map (NicePrint.prettyStringOfTy denv)
|> String.concat ", "
prefix + (FSComp.SR.csNoOverloadsFoundTypeParametersPrefixPlural args) + suffix
| [] -> None
| [_] -> Some (FSComp.SR.csNoOverloadsFoundTypeParametersPrefixSingular genericParameters)
| _ -> Some (FSComp.SR.csNoOverloadsFoundTypeParametersPrefixPlural genericParameters)

let formatOverloads (overloads: OverloadInformation list) =
overloads
|> List.map (fun overload -> overload.OverloadMethodInfo denv m)
|> List.sort
|> List.map FSComp.SR.formatDashItem
|> String.concat nl
let formatTraitInfo (cx: TraitConstraintInfo) =

let prettyArgTys =
cx.ArgTys
|> List.map (NicePrint.prettyStringOfTy denv)
|> String.concat ", "

[ sprintf "cx.ArgTys %s" prettyArgTys
sprintf "cx.MemberFlags %A" cx.MemberFlags
sprintf "cx.MemberName %A" cx.MemberName
sprintf "cx.ReturnType %A" (cx.ReturnType |> Option.map (NicePrint.prettyStringOfTy denv))
sprintf "cx.Solution %A" cx.Solution
sprintf "cx._Tys %A" (cx._Tys |> List.map (NicePrint.prettyStringOfTy denv))

] |> String.concat nl
let cx, msg =

let msg =
let optionalParts =
[knownReturnType; genericParametersMessage; argsMessage]
|> List.choose id
|> String.concat (nl + nl)
|> function | "" -> String.Empty
| result -> nl + nl + result + nl + nl

match failure with
| NoOverloadsFound (methodName, overloads, cx) ->
cx
, FSComp.SR.csNoOverloadsFound methodName
+ (knownReturnType cx)
+ (genericParametersMessage cx)
+ argsMessage
+ (FSComp.SR.csAvailableOverloads (formatOverloads overloads))
| PossibleCandidates (methodName, methodNames, cx) ->
cx
, (let msg = FSComp.SR.csMethodIsOverloaded methodName
match methodNames with
| [] -> msg
| names ->
let overloads = FSComp.SR.csCandidates (formatOverloads names)
msg
+ (knownReturnType cx)
+ (genericParametersMessage cx)
+ argsMessage
+ overloads)

let traitInfo = cx |> Option.map (fun cx -> nl + nl + "TRAIIAT" + nl + formatTraitInfo cx + nl + nl) |> Option.defaultValue ""
os.Append (msg + traitInfo) |> ignore
| NoOverloadsFound (methodName, overloads, _) ->
FSComp.SR.csNoOverloadsFound methodName
+ optionalParts
+ (FSComp.SR.csAvailableOverloads (formatOverloads overloads))
| PossibleCandidates (methodName, [], _) ->
FSComp.SR.csMethodIsOverloaded methodName
| PossibleCandidates (methodName, overloads, _) ->
FSComp.SR.csMethodIsOverloaded methodName
+ optionalParts
+ FSComp.SR.csCandidates (formatOverloads overloads)

os.Append msg |> ignore

| UnresolvedConversionOperator(denv, fromTy, toTy, _) ->
let t1, t2, _tpcs = NicePrint.minimalStringsOfTwoTypes denv fromTy toTy
Expand Down
68 changes: 52 additions & 16 deletions src/fsharp/NicePrint.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,10 +1019,26 @@ module private PrintTypes =
|> List.map (sepListL (wordL (tagPunctuation "*")))
allArgsL

let layoutReturnType denv env rty = layoutTypeWithInfoAndPrec denv env 4 rty

let layoutGenericParameterTypes denv env =
function
| [] -> emptyL
| genParamTys ->
(wordL (tagPunctuation "<"))
^^
(
genParamTys
|> List.map (layoutTypeWithInfoAndPrec denv env 4)
|> sepListL (wordL (tagPunctuation ","))
)
^^
(wordL (tagPunctuation ">"))

/// Layout a single type used as the type of a member or value
let layoutTopType denv env argInfos rty cxs =
// Parenthesize the return type to match the topValInfo
let rtyL = layoutTypeWithInfoAndPrec denv env 4 rty
let rtyL = layoutReturnType denv env rty
let cxsL = layoutConstraintsWithInfo denv env cxs
match argInfos with
| [] -> rtyL --- cxsL
Expand Down Expand Up @@ -1118,23 +1134,43 @@ module private PrintTypes =
nameL
nameL ^^ wordL (tagPunctuation ":") ^^ tauL


let prettyLayoutOfUnresolvedMethodCallArguments denv typarInst argInfos =

/// layouts the elements of an unresolved overloaded method call:
/// argInfos: unammed and named arguments
/// retTy: return type
/// genParamTy: generic parameter types
let prettyLayoutsOfUnresolvedOverloading denv argInfos retTy genParamTys =
let _niceMethodTypars, typarInst =
let memberToParentInst = List.empty
let typars = argInfos |> List.choose (function (TType.TType_var typar,_) -> Some typar | _ -> None)
let methTyparNames = typars |> List.mapi (fun i tp -> if (PrettyTypes.NeedsPrettyTyparName tp) then sprintf "a%d" (List.length memberToParentInst + i) else tp.Name)
PrettyTypes.NewPrettyTypars memberToParentInst typars methTyparNames
let retTy = instType typarInst retTy
let argInfos = prettyArgInfos denv typarInst argInfos
let argInfos,retTy,genParamTys, cxs =
let typesWithDiscrimants =
[
yield 0uy,retTy
for ty,_ in argInfos do
yield 1uy, ty
for ty in genParamTys do
yield 2uy, ty
]
let typesWithDiscrimants,typarsAndCxs = PrettyTypes.PrettifyDiscriminantAndTypePairs denv.g typesWithDiscrimants
let argInfos =
typesWithDiscrimants
|> List.choose (function (1uy,ty) -> Some ty | _ -> None)
|> List.zip argInfos
|> List.map (fun ((_,argInfo),tTy) -> tTy, argInfo)
let genParamTys =
typesWithDiscrimants
|> List.choose (function (2uy,ty) -> Some ty | _ -> None)
argInfos, retTy, genParamTys, typarsAndCxs

let ___cxs =
argInfos
|> List.map (fun (tTy, _) ->
let __tTy,constraints = (PrettyTypes.PrettifyType denv.g tTy)
constraints
)

// don't really know what to do to work with CollectInfo below with all the constraints...
let cxs = []

let env = SimplifyTypes.CollectInfo true (List.collect (List.map fst) [argInfos]) cxs
layoutArgInfos denv env [argInfos]
let cxsL = layoutConstraintsWithInfo denv env env.postfixConstraints
List.foldBack (---) (layoutArgInfos denv env [argInfos]) cxsL
, layoutReturnType denv env retTy
, layoutGenericParameterTypes denv env genParamTys

let prettyLayoutOfType denv ty =
let ty, cxs = PrettyTypes.PrettifyType denv.g ty
Expand Down Expand Up @@ -1275,7 +1311,7 @@ let layoutConst g ty c = PrintTypes.layoutConst g ty c

let prettyLayoutOfMemberSig denv x = x |> PrintTypes.prettyLayoutOfMemberSig denv
let prettyLayoutOfUncurriedSig denv argInfos tau = PrintTypes.prettyLayoutOfUncurriedSig denv argInfos tau
let prettyLayoutOfUnresolvedMethodCallArguments = PrintTypes.prettyLayoutOfUnresolvedMethodCallArguments
let prettyLayoutsOfUnresolvedOverloading denv argInfos retTy genericParameters = PrintTypes.prettyLayoutsOfUnresolvedOverloading denv argInfos retTy genericParameters
//-------------------------------------------------------------------------

/// Printing info objects
Expand Down
4 changes: 4 additions & 0 deletions src/fsharp/TastOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2509,6 +2509,10 @@ module PrettyTypes =
let PrettifyType g x = PrettifyThings g id id x
let PrettifyTypePair g x = PrettifyThings g (fun f -> foldPair (f, f)) (fun f -> mapPair (f, f)) x
let PrettifyTypes g x = PrettifyThings g List.fold List.map x
let PrettifyDiscriminantAndTypePairs g x =
let tys, cxs = (PrettifyThings g List.fold List.map (x |> List.map snd))
List.zip (List.map fst x) tys, cxs

let PrettifyCurriedTypes g x = PrettifyThings g (fun f -> List.fold (List.fold f)) List.mapSquared x
let PrettifyCurriedSigTypes g x = PrettifyThings g (fun f -> foldPair (List.fold (List.fold f), f)) (fun f -> mapPair (List.mapSquared f, f)) x

Expand Down
2 changes: 2 additions & 0 deletions src/fsharp/TastOps.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,8 @@ module PrettyTypes =
val PrettifyTypePair : TcGlobals -> TType * TType -> (TType * TType) * TyparConstraintsWithTypars

val PrettifyTypes : TcGlobals -> TTypes -> TTypes * TyparConstraintsWithTypars

val PrettifyDiscriminantAndTypePairs : TcGlobals -> ('Discriminant * TType) list -> ('Discriminant * TType) list * TyparConstraintsWithTypars

val PrettifyInst : TcGlobals -> TyparInst -> TyparInst * TyparConstraintsWithTypars

Expand Down