-
Notifications
You must be signed in to change notification settings - Fork 842
Context propagates wrongly => wrong error message #1827
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
Conversation
src/fsharp/TypeChecker.fs
Outdated
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 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?
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.
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.
|
One of the issues is: we want to keep the context for the result type check, but erase for x and for whaterver happens inside of f. |
|
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 |
|
something like: instead of: |
c7da80b to
cb3fa24
Compare
|
looks like #1827 (comment) is not enough since it forces us for type hints: cb3fa24 |
|
and there are coming more. @dsyme is there another way to let the context only work for the return type check? |
|
That sort of implementation looks much more robust (once it's green) |
c5cedf6 to
7d57faf
Compare
|
Ok this strategy didn't work, but now I think we can do this: 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. |
src/fsharp/CompileOps.fs
Outdated
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.
Now git blame doesn't show the original author, might be a good idea to add it (if it is even correct)
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.
what?
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 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 ...
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.
Yeah I think I already fucked up couple of such comments. But tbf I assume
most "original authors" are the initial OSS commit anyways.
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.
If it helps that comment is from me :)
06ce5fb to
1d8b1d0
Compare
|
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. |
|
All green. Yay. Finally |





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: