Skip to content

VS crashes if you rename an F# symbol where it is at the top of a file or unsaved file #4655

@cartermp

Description

@cartermp

Using 15.6.4 and latest master installed into it, attempt to rename Record in the following code:

type Record = { IntVal: int; StringVal: string }

[<AbstractClass>]
type AbstractFoo<'T>() =
    abstract member Foo: 'T -> 'T

type C() =
    inherit AbstractFoo<Record>()
    override __.Foo(r) = { r with IntVal = 12 }

After typing the first character, the inline rename service will crash, followed by VS crashing.

This is the stack trace in the activity log:

System.NullReferenceException: Object reference not set to an instance of an object. at 
Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.CommitCore(IWaitContext waitContext, Boolean previewChanges) at 
Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.<>c__DisplayClass71_0.<Commit>b__0(IWaitContext waitContext) at 
Microsoft.VisualStudio.LanguageServices.Implementation.Utilities.VisualStudioWaitIndicator.Wait(String title, String message, Boolean allowCancel, Boolean showProgress, Action`1 action) at 
Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.Commit(Boolean previewChanges) at 
Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.RenameCommandHandler.CommitIfActive(EditorCommandArgs args) at 
Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.RenameCommandHandler.CommitIfActiveAndCallNextHandler(EditorCommandArgs args, Action nextHandler) at 
Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.RenameCommandHandler.HandlePossibleTypingCommand(EditorCommandArgs args, Action nextHandler, Action`1 actionIfInsideActiveSpan) at 
Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.RenameCommandHandler.ExecuteCommand(TypeCharCommandArgs args, Action nextHandler, CommandExecutionContext context) at 
Microsoft.VisualStudio.Commanding.CommandHandlerExtensions.ExecuteCommand[T](ICommandHandler commandHandler, T args, Action nextCommandHandler, CommandExecutionContext executionContext) at 
Microsoft.VisualStudio.UI.Text.Commanding.Implementation.EditorCommandHandlerService.<>c__DisplayClass14_1`1.<Execute>b__1() at 
Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call) --- End of stack trace from previous location where exception was thrown --- at 
Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

Currently this makes it impossible to test out a fix for #4231 😢

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions