-
Notifications
You must be signed in to change notification settings - Fork 845
Description
I thought we already had an issue related to this, but I have searched, and apparently there isn't. It may be that what I almost remember is a comment somewhere from somebody on the Visual F# team about this. Maybe one to three years back. Anyway, it's a good time to fix it I think. Not that it's important.
The following will result in compile error FS0001 : This expression was expected to have type 'string' but here has type ''a option'
let s: string = Some "Hello"
In Visual Studio 2019, 16.0.2, the error is frequently reported twice in the Error List pane. At first I thought this was once from Intellisense and once from Build, and that IntelliSense produced the one with line breaks. And I thought the problem was perhaps that because one had breaks and the other not, they weren't identified as the same error. Now I've started digging, and I am not sure about anything anymore. It seems to be less consistent the more I try to reproduce the behavior. Have a look at these screenshots.
Build + IntelliSense
Build Only
The screenshot with and without line breaks I just can't get back at the moment, in spite of that being the norm. (Had to log in remote to my work machine to get an earlier screenshot.) The screenshot with two identical, and with only "Build", I only got once ever. Funny thing is that I had no problem reproducing the first frequently when I didn't really try - earlier today and yesterday. It's a variation of the "only on my machine" theme - ha ha.
Additional note
When I pasted the error message from VS Error List pane into here, there were characters displayed as square boxes inside the error message itself, at the positions where I would expect line breaks to be in the screenshot with line breaks. But the error message I copied came from the screenshot with two lines without breaks.
So now I did one more experiment. I pasted the error message with breaks. This resulted in no square boxes, but proper line breaks, just like in Visual Studio. Here you see it straight from VS:
This expression was expected to have type
'string'
but here has type
''a option'
My guess is that the boxes were LF only, while in the text above there are proper CR+LF. Or perhaps even the other way round.
Repro steps
Try with the code snippet, but don't expect reliable results.

