Skip to content

Semantic Highlighting regression: optional parameter still highlights as namespace (GetPartialLongNameEx missing fix) #19591

@yTex10

Description

@yTex10

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).


VS highlighting bug with optional parameter

Repro steps

  1. Open a file with this code:
type TestType() =
    member x.TestOptional(?optionalParameter) = optionalParameter
  1. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions