Summary
Despite the fix for optional parameter identifier extraction (in QuickParse.GetCompleteIdentifierIsland) and release in 10.0.200, semantic highlighting in Visual Studio (18.5+, FSharp 10.0.202) still incorrectly colors functions with optional parameters as if the entire function is a namespace (see screenshot below).
Repro steps
- Open a file with this code:
type TestType() =
member x.TestOptional(?optionalParameter) = optionalParameter
- Observe that
TestOptional function and its contents get highlighted as a namespace or type, not as a method/member and parameter.
Expected behavior
Only optionalParameter should be highlighted as a parameter, and the function as a member.
Actual behavior
The whole function is colored as if it were a namespace. Note that using just a ? as the parameter name (e.g. x.TestOptional(?)) will highlight the ? as an identifier(and yes, that compiles), but the highlighting error is going to occur after you add the parameter name(identifier) after the ? symbol.
Cause
- The fix was applied to
QuickParse.GetCompleteIdentifierIsland, but not to QuickParse.GetPartialLongNameEx, which is used for semantic classification and highlighting in Visual Studio.
- The test suite only covers
GetCompleteIdentifierIsland, so tests falsely pass.
GetPartialLongNameEx lacks recognition of the syntax ?identifier, so everything after ? is not recognized as a proper parameter and falls back to treating the context as a namespace.
Known workaround
None yet.
Related info
Recommendation
Apply the same logic for optional parameters (? handling) in GetPartialLongNameEx, just as in GetCompleteIdentifierIsland, and add/expand test coverage for this case.
Reported by Copilot user after upgrade to 10.0.202 & VS 18.5.
CC: @fsharp/vs-editor-tools @fsharp/compiler-contributors
Summary
Despite the fix for optional parameter identifier extraction (in
QuickParse.GetCompleteIdentifierIsland) and release in 10.0.200, semantic highlighting in Visual Studio (18.5+, FSharp 10.0.202) still incorrectly colors functions with optional parameters as if the entire function is a namespace (see screenshot below).Repro steps
TestOptionalfunction and its contents get highlighted as a namespace or type, not as a method/member and parameter.Expected behavior
Only
optionalParametershould be highlighted as a parameter, and the function as a member.Actual behavior
The whole function is colored as if it were a namespace. Note that using just a
?as the parameter name (e.g.x.TestOptional(?)) will highlight the?as an identifier(and yes, that compiles), but the highlighting error is going to occur after you add the parameter name(identifier) after the?symbol.Cause
QuickParse.GetCompleteIdentifierIsland, but not toQuickParse.GetPartialLongNameEx, which is used for semantic classification and highlighting in Visual Studio.GetCompleteIdentifierIsland, so tests falsely pass.GetPartialLongNameExlacks recognition of the syntax?identifier, so everything after?is not recognized as a proper parameter and falls back to treating the context as a namespace.Known workaround
None yet.
Related info
Recommendation
Apply the same logic for optional parameters (
?handling) inGetPartialLongNameEx, just as inGetCompleteIdentifierIsland, and add/expand test coverage for this case.Reported by Copilot user after upgrade to 10.0.202 & VS 18.5.
CC: @fsharp/vs-editor-tools @fsharp/compiler-contributors