Skip to content

Conversation

@forki
Copy link
Contributor

@forki forki commented Nov 24, 2016

The “context” is persisting into the checking of the body of the “else” branch, but not being reset.
Therefor we get too specific error message:

image

  • Reproduce in test
  • fix context propagation

@forki
Copy link
Contributor Author

forki commented Nov 24, 2016

similar case:

image

@forki
Copy link
Contributor Author

forki commented Nov 24, 2016

image

@forki
Copy link
Contributor Author

forki commented Nov 24, 2016

Arg this destroyed this case:

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect you'll have to clear on all recursive calls. I think it may be more accurate to just pass the ctxt as an explicit parameter to TcExpr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not easy. we have to be very careful to not erase from the wrong position.
Actually I'm not even convinced if the "context" is the best idea here.

@forki
Copy link
Contributor Author

forki commented Nov 24, 2016

@dsyme:

One of the issues is:

// f x
| SynExpr.App (hpa,_,func,arg,mFuncAndArg) ->
    TcExprThen cenv overallTy env tpenv func ((DelayedApp (hpa, arg, mFuncAndArg)):: delayed)

we want to keep the context for the result type check, but erase for x and for whaterver happens inside of f.

@forki
Copy link
Contributor Author

forki commented Nov 24, 2016

I think what we actually want to do is not set a context here at all. We just want to make the very last UnifyTypes call in that else expression aware of the situation

@forki
Copy link
Contributor Author

forki commented Nov 24, 2016

something like:

            let tempty = NewInferenceType ()
            let e3',tpenv = TcExprThatCanBeCtorBody cenv tempty env tpenv e3 

            let env = { env with eContextInfo = ContextInfo.ElseBranch }                 
            UnifyTypes cenv env e3.Range overallTy tempty

instead of:

            let env = { env with eContextInfo = ContextInfo.ElseBranch } 
            let e3',tpenv = TcExprThatCanBeCtorBody cenv overallTy env tpenv e3 

@forki forki force-pushed the contextprop branch 8 times, most recently from c7da80b to cb3fa24 Compare November 24, 2016 16:33
@forki
Copy link
Contributor Author

forki commented Nov 24, 2016

looks like #1827 (comment) is not enough since it forces us for type hints: cb3fa24

@forki
Copy link
Contributor Author

forki commented Nov 24, 2016

and there are coming more.

@dsyme is there another way to let the context only work for the return type check?

@dsyme
Copy link
Contributor

dsyme commented Nov 24, 2016

That sort of implementation looks much more robust (once it's green)

@forki forki force-pushed the contextprop branch 4 times, most recently from c5cedf6 to 7d57faf Compare November 24, 2016 20:04
@forki
Copy link
Contributor Author

forki commented Nov 24, 2016

Ok this strategy didn't work, but now I think we can do this:

            let env = { env with eContextInfo = ContextInfo.ElseBranchResult e3.Range }
            let e3',tpenv = TcExprThatCanBeCtorBody cenv overallTy env tpenv e3 
            e3',SequencePointAtTarget,tpenv

and at the error reporting site we check if the type error comes from the right range. that's basically narrowing the context to a minimum.

@forki
Copy link
Contributor Author

forki commented Nov 24, 2016

This is how it felt:

aua

But I think this is now the correct strategy and my manual checks are all working.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now git blame doesn't show the original author, might be a good idea to add it (if it is even correct)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean if I ever go across a comment like this I might want to talk with the original author (which would be you now). But that was really just a suggestion, as one can figure it out with multiple git calls as well ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think I already fucked up couple of such comments. But tbf I assume
most "original authors" are the initial OSS commit anyways.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it helps that comment is from me :)

@forki forki force-pushed the contextprop branch 5 times, most recently from 06ce5fb to 1d8b1d0 Compare November 25, 2016 08:46
@forki
Copy link
Contributor Author

forki commented Nov 25, 2016

This is fixed as well 👍
image

@forki
Copy link
Contributor Author

forki commented Nov 25, 2016

this is ready for review. I had to disable the nice async error message for now since the range where the exception happens is inside the "return" part. So that can't be found right now. I leave that for F# 4.2

But this is now removign all the false positive warnings and should be merged to FCS as soon as possible since Ionide and Xamarin Studio? (cc @Krzysztof-Cieslak @nosami) are already using it.

@forki
Copy link
Contributor Author

forki commented Nov 25, 2016

All green. Yay. Finally

@dsyme dsyme merged commit ecb4307 into dotnet:master Nov 27, 2016
@forki forki deleted the contextprop branch November 28, 2016 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants