fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Using `delegate` keyword breaks semantic highlighting

Open T-Gro opened this issue 1 year ago • 1 comments

image

Microsoft Visual Studio Enterprise 2022 Version 17.11.0 Preview 1.0 [34801.192.main] VisualStudio.17.IntPreview/17.11.0-pre.1.0+34801.192.main

Visual F# Tools 17.10.0-dev Microsoft Visual F# Tools

The screenshot above was done custom-built .vsix for the nullness feature branch. For a regular preview VS, it is differently wrong:

image Microsoft Visual Studio Enterprise 2022 Version 17.10.0 Preview 2.0 VisualStudio.17.Preview/17.10.0-pre.2.0+34707.107

Visual F# Tools 17.10.0-beta.24127.3+b57dee7cec971021547a7b8a36a46d7271fea99e Microsoft Visual F# Tools

This is self-contained code to reproduce this:

[<RequireQualifiedAccess>]
type ErrorReportType =
    | Warning
    | Error

type ResolvingErrorReport = delegate of ErrorReportType * int * string -> unit

Another snippet demonstrating this is clearly wrong is repeating the same type more types, yet getting difference in the color:

type ResolvingErrorReport = delegate of int * System.Int32 * System.Int32 * int -> unit

image

T-Gro avatar Apr 03 '24 11:04 T-Gro

My guess is it may be related to converting the delegate representation to another shape during the type checking (or even during the parsing). I think there're additional members added to the tree and then their symbols are reported during the type checking. If this is true, then a fix could be as follows: mark ranges of these members synthetic and then ignore symbols with synthetic ranges during semantic highlighting.

auduchinok avatar Apr 03 '24 11:04 auduchinok