Skip to content

An exception in the ChangePrefixNegationToInfixSubstraction code fix #16356

@psfinaki

Description

@psfinaki

This code throws:

type MyType = { Value: int }

let test = { Value = 42 }x

The stack trace:

System.ArgumentOutOfRangeException : Specified argument was out of the range of valid values.
Parameter name: index
   at Microsoft.VisualStudio.Text.Implementation.StringRebuilderForString.get_Item(Int32 index)
   at async StartupCode$FSharp-Editor(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.VisualStudio.FSharp.Editor.CodeFixExtensions.CodeFixContext-RegisterFsharpFix@93(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeFixes.CodeFixService.GetCodeFixesAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)

This happens because the code above happens to produce FS0003 (This value is not a function) whereas the code fix searches for the - sign in the code and fails to find one here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-LangService-CodeFixesCode fixes associated with diagnosticsBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.good first issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions