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

Implement ref switch expressions #69575

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

Rekkonnect
Copy link
Contributor

@Rekkonnect Rekkonnect commented Aug 17, 2023

This draft PR is approved by @CyrusNajmabadi in offline conversations. Feature and PR review is not expected to happen before the release of C# 12.

The feature's spec is dotnet/csharplang#7352

Currently handled

Features

  • Syntax parsing
  • Variable assignment
  • Direct return in method body
  • Direct assignment to the ref
  • Direct compound assignment to the ref
  • Ref and value escaping based on scope
  • Readonly ref kind

Handy features

  • IDE suggestions for ref within arms
    • Always suggest ref, even when the switch expression does not have a ref on the left of it
    • This already works, this PR does not need to address this

Errors

  • Not using ref returned from the expression
  • Not all arms have ref or throw
  • C# preview required
  • ref on switch expression not returning ref (better hint about the feature)

@ghost ghost added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Aug 17, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee. untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant