-
Notifications
You must be signed in to change notification settings - Fork 271
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
Use collection expressions where possible #6079
Use collection expressions where possible #6079
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Approved from previous PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like an excellent improvement for the maintenance of the code. A few comments.
@@ -22,8 +22,9 @@ private void InitializeAttributes() { | |||
Attributes.ContainsBool(Attributes, "split", ref splitMatch); | |||
foreach (var c in Cases) { | |||
if (!Attributes.Contains(c.Attributes, "split")) { | |||
List<Expression> args = new List<Expression>(); | |||
args.Add(Expression.CreateBoolLiteral(c.Origin, splitMatch)); | |||
List<Expression> args = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow nice syntax at least !
new List<TypeParameter>(new TypeParameter[] { new TypeParameter(SourceOrigin.NoToken, new Name("arg"), TypeParameter.TPVarianceSyntax.NonVariant_Strict) }), | ||
new List<MemberDecl>(), attrs, false, null) { | ||
[ | ||
.. new TypeParameter[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this weird syntax? Am I understanding correctly that we are creating a list from an inline array? Can we just create now the list using [] ?
Bpl.Expr.Literal(0) | ||
]; | ||
// {:subsumption 0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bpl.Expr.Literal(0) | |
]; | |
// {:subsumption 0} | |
// {:subsumption 0} | |
Bpl.Expr.Literal(0) | |
]; |
("p2", "Always true."), | ||
("p3", "Always true every time."), | ||
}); | ||
", [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent that it also works with named tuples
@@ -21,7 +21,7 @@ public void TestConcatSequence() { | |||
Thread t = new Thread(delegate () { | |||
left.right = null; | |||
Thread.Sleep(100); // Ensure ComputeElements() does not work immediately | |||
left.elmts = new List<int>() { 1, 2 }.ToImmutableArray(); | |||
left.elmts = [.. new List<int>() { 1, 2 }]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left.elmts = [.. new List<int>() { 1, 2 }]; | |
left.elmts = [1, 2]; |
I hope it works !
Remaining comments addressed in #6083 |
### What was changed? Small code improvements to address comments from #6079 ### How has this been tested? Pure refactoring <small>By submitting this pull request, I confirm that my contribution is made under the terms of the [MIT license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
What was changed?
How has this been tested?
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.