Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddMissingEqualsToTypeDefinitionCodeFixProvider crash #15685

Closed
Tracked by #15408
0101 opened this issue Jul 26, 2023 · 3 comments · Fixed by #15763
Closed
Tracked by #15408

AddMissingEqualsToTypeDefinitionCodeFixProvider crash #15685

0101 opened this issue Jul 26, 2023 · 3 comments · Fixed by #15763
Assignees
Labels
Area-LangService-CodeFixes Code fixes associated with diagnostics Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. Needs-Repro
Milestone

Comments

@0101
Copy link
Contributor

0101 commented Jul 26, 2023

This suddenly popped up when editing some code - which wasn't relevant to the code fix (no type in sight). But finding the broken ExactlyOne should be enough to fix this.

image

System.ArgumentException : The input sequence contains more than one element.
Parameter name: source
   at Microsoft.FSharp.Collections.SeqModule.ExactlyOne[T](IEnumerable`1 source)
   at async StartupCode$FSharp-Editor(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.VisualStudio.FSharp.Editor.CodeFixExtensions.CodeFixContext-RegisterFsharpFix@85(<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>)
@0101 0101 added Bug Area-LangService-CodeFixes Code fixes associated with diagnostics Needs-Triage labels Jul 26, 2023
@github-actions github-actions bot added this to the Backlog milestone Jul 26, 2023
@vzarytovskii
Copy link
Member

Yeah, as a rule of thumb, we should not be throwing in vs, but instead reporting errors using built-in mechanism

@0101 0101 added Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. and removed Needs-Triage labels Jul 31, 2023
@psfinaki psfinaki modified the milestones: Backlog, August-2023 Jul 31, 2023
@psfinaki psfinaki mentioned this issue Jul 31, 2023
85 tasks
@psfinaki
Copy link
Member

psfinaki commented Aug 3, 2023

Repro:

let f x = 
    match x with
    | _ ->
        let _ = [
            x with
        ]
repro.mp4

Indeed, we have two different FS0010 here:
image

@0101
Copy link
Contributor Author

0101 commented Aug 4, 2023

I would suggest removing all unsafe operations like exactlyOne, head, etc. From the code fixes (or really anywhere where it can crash in VS) regardless of if the underlying cause is legitimate. Instead of crashing report telemetry so we'll find out about it.

Could be also a nice analyzer to highlight all of these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-LangService-CodeFixes Code fixes associated with diagnostics Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. Needs-Repro
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants