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

IDE0055 triggered on no space after spread operator #71219

Closed
jez9999 opened this issue Dec 11, 2023 · 7 comments
Closed

IDE0055 triggered on no space after spread operator #71219

jez9999 opened this issue Dec 11, 2023 · 7 comments
Labels
Area-IDE Resolution-By Design The behavior reported in the issue matches the current design untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@jez9999
Copy link

jez9999 commented Dec 11, 2023

I get the following warning because there's no space after my spread operator:

image

I don't even see what formatting option would apply to this, and in any case I don't want a space after my spread operators. It shouldn't give this warning.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 11, 2023
@CyrusNajmabadi
Copy link
Member

As with most of formatting, there is no option to control things. The formatting for spreads simply is this way. If not desired, it can be suppressed in these locations, or the analyzer can be entirely disabled.

Requests to support arbitrary formatting rules falls under a general formatting extensibility system which we are considering, but have no timeline on.

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2023
@jez9999
Copy link
Author

jez9999 commented Dec 12, 2023

@CyrusNajmabadi Is there a Github issue for said new formatting system?

@sharwell sharwell added the Resolution-By Design The behavior reported in the issue matches the current design label Apr 16, 2024
@sharwell
Copy link
Member

I agree that the space after .. looks incorrect.

@CyrusNajmabadi
Copy link
Member

Space there was chosen by ldm, and corresponds to the same space we chose for the corresponding slice pattern form.

This is not an operator, and does not 'bind tightly' (which is when we think there should be no space.

As an example: !b ? c : d here we want !b as that binds tightly to b and not the whole expression.

But that's not the case with the spread element. .. a ? b : c is .. (a ? b : c) not (..a) ? b : c. The space is intentionally there to not make it feel like it's operating directly on the things it touches.

Put another way, it's not a unary expression, so it gets a space

@sharwell
Copy link
Member

sharwell commented Apr 17, 2024

The space is intentionally there to not make it feel like it's operating directly on the things it touches.

Can you show sample code defining a, b, and c such that both of the following compile?

  1. .. (a ? b : c)
  2. (..a) ? b : c

The post implicitly claims that users may be confused about the binding precedence, but I'm having a hard time coming up with a case where that could happen.

It feels like we penalized all actual cases to account for a case that is either rare or doesn't exist, or maybe I'm just not seeing it yet.

@CyrusNajmabadi
Copy link
Member

The point isn't that both compile, it's that the formatting implies one over the other.

@CyrusNajmabadi
Copy link
Member

It feels like we penalized all actual cases

There's no penalty. We made an informed choice to align with slice patterns so that construction and deconstruction would pair up and format uniformly. And we used our general view here on precedence to dictate for both how we felt the formatting should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Resolution-By Design The behavior reported in the issue matches the current design untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

3 participants