Skip to content

Conversation

@brianrourkeboll
Copy link
Contributor

@brianrourkeboll brianrourkeboll commented Dec 29, 2024

This change incidentally also prevents the code fix from suggesting a "fix" that would be invalid in various scenarios,1 e.g.:

(Disposable) arg // Formerly suggested `(new Disposable) arg`, now suggests nothing.
xs |> List.map Disposable // Formerly suggested `xs |> List.map new Disposable`, now suggests nothing.

Footnotes

  1. We could in theory update the code fix to suggest new (Disposable)(arg) (or even new Disposable(arg)), xs |> List.map (fun x -> new Disposable(x)), etc., for such scenarios, but I considered that out of scope for this PR—and perhaps altogether, since transformations like xs |> List.map (fun x -> new Disposable(x)) also may not be valid, depending on the type of the constructor argument! For example, if xs is a unit list, then transforming xs |> List.map Disposable to xs |> List.map (fun x -> new Disposable(x)) is not valid.

@brianrourkeboll brianrourkeboll changed the title Add parens when needed when adding new keyword Wrap arg in parens when needed when adding new keyword Dec 29, 2024
Copy link
Member

@TheAngryByrd TheAngryByrd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!!

@TheAngryByrd TheAngryByrd merged commit 524c2da into ionide:main Dec 31, 2024
14 checks passed
@brianrourkeboll brianrourkeboll deleted the add-new-with-parens branch December 31, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants