-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CompilerPerf] Pretify ConstrainsSolver method #5141
Conversation
The method wasn't readable at all before now it's better.
I'm open to converting the whole of ConstraintSolver.fs to use One note: we may need to add a |
src/fsharp/ConstraintSolver.fs
Outdated
|
||
|
||
let calledObjArgTys = calledMeth.CalledObjArgTys(m) | ||
if minst.Length <> uminst.Length then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this outside the trackErrors
?
src/fsharp/ConstraintSolver.fs
Outdated
do! calledMeth.ArgSets | ||
|> IterateD (fun argSet -> | ||
argSet.AssignedNamedArgs |> IterateD (fun arg -> subsumeArg arg.CalledArg arg.CallerArg)) | ||
do! assignedItemSetters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use a for
loop here, since trackErrors
has a For
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to implement more methods so the for do is usable.
src/fsharp/ConstraintSolver.fs
Outdated
|> IterateD (fun argSet -> | ||
if argSet.UnnamedCalledArgs.Length <> argSet.UnnamedCallerArgs.Length then ErrorD(Error(FSComp.SR.csArgumentLengthMismatch(), m)) else | ||
Iterate2D subsumeArg argSet.UnnamedCalledArgs argSet.UnnamedCallerArgs) | ||
do! calledMeth.ParamArrayCalledArgOpt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be best to use
match calledMeth.ParamArrayCalledArgOpt with
| None -> ()
| Some calledArg ->
...
src/fsharp/ConstraintSolver.fs
Outdated
trackErrors { | ||
do! Iterate2D unifyTypes minst uminst | ||
do! | ||
if not (permitOptArgs || isNil unnamedCalledOptArgs) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you don't need the do!
, you can go straight into the if
and then return!
on each branch
trackErrors {
do! Iterate2D unifyTypes minst uminst
if not (permitOptArgs || isNil unnamedCalledOptArgs) then
return! ErrorD(Error(FSComp.SR.csOptionalArgumentNotPermittedHere(), m))
else
....
cool ok you can see on master...realvictorprm:fix-3814 that I already started implementing required methods so |
Signed-off-by: realvictorprm <mueller.vpr@gmail.com>
Is this the right direction @dsyme? |
@dotnet-bot test this please |
@dotnet-bot test Ubuntu16.04 Release_fcs Build please |
The method wasn't readable at all before now it's better.
Converted the code to use an computation expression.