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

With expression #262

Merged
merged 2 commits into from
Aug 1, 2023
Merged

With expression #262

merged 2 commits into from
Aug 1, 2023

Conversation

wise0704
Copy link
Contributor

@wise0704 wise0704 commented Aug 1, 2023

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/with-expression

Syntax is identical to:

  • LHS: switch expression (?<!\.)\b
  • RHS: anonymous object b\s*(?=\{|$) + #initializer-expression + (?<=\})
  • context & op. precedence: switch expression

I chose keyword.other.with.cs as it seemed most appropriate, but let me know if there's a better name for it.

Related: #239

Copy link
Member

@JoeRobich JoeRobich left a comment

Choose a reason for hiding this comment

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

The change looks great. Thanks @wise0704!

@wise0704
Copy link
Contributor Author

wise0704 commented Aug 1, 2023

Seems like both new { } and with { } fail when the line ends with a comment before { on the next line:

var a = new // this will not match
{ ... };
var b = a with // so this one won't either
{ ... };

Should I just fix both in this PR? I guess changing the lookahead to (?=\{|//|/*|$) should fix it.

@JoeRobich
Copy link
Member

Should I just fix both in this PR?

Since this was a pre-existing issue, we can take the fix separately.

@JoeRobich JoeRobich merged commit 7163532 into dotnet:main Aug 1, 2023
2 checks passed
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