-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Test plan for "collection literals" #66418
Comments
dotnet-issue-labeler
bot
added
the
untriaged
Issues and PRs which have not yet been triaged by a lead
label
Jan 13, 2023
jcouv
removed
the
untriaged
Issues and PRs which have not yet been triaged by a lead
label
Jan 13, 2023
This was referenced Jun 30, 2023
This was referenced Jul 20, 2023
Closed
This was referenced Jul 31, 2023
Merged
Merged
Closed
This was referenced Aug 19, 2023
This was referenced Sep 16, 2023
This was referenced Dec 6, 2023
This was referenced Jan 18, 2024
Merged
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The feature was renamed to "collection expressions".
Championed issue: dotnet/csharplang#5354
Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-12.0/collection-expressions.md
Compiler
General Concerns
LanguageVersionDiagnostics
)Parsing
a?[b]
(CollectionExpressionParsingTests.ConditionalAmbiguityX
)CollectionExpressionParsingTests.AttributeOnStartOfLambda
,CollectionExpressionParsingTests.TopLevelDotAccess_AttributeAmbiguityX
)CollectionExpressionParsingTests.CastVsIndexAmbiguityX
)(a)[b]
(a?)[b]
(a<b>)[c]
_ = x ? y?[0] : z; // syntax error
CollectionExpressionParsingTests.AttemptToImmediatelyIndexInTopLevelStatement
)Semantics
async
methodsBestCommonType_03
,_04
)TypeInference_03
,_04
)TypeInference_37
)var
,object
,dynamic
T[]
(Array_*
)T[,]
(Array_04
)Span<T>
,ReadOnlySpan<T>
(Span_*
)IEnumerable
,ICollection
,IList
(InterfaceType_01
)IEnumerable<T>
,ICollection<T>
,IList<T>
,IReadOnlyCollection<T>
,IReadOnlyList<T>
(InterfaceType_02
)CollectionInitializerType_01
,_02
,TypeParameter_*
)inline arraysAdd()
method (CollectionInitializerType_03
,CollectionInitializerType_12
)CollectionInitializerType_05
)int capacity
CollectionInitializerType_ConstructorOptionalParameters
)params
parameter (CollectionInitializerType_ConstructorParamsArray
)RefStruct_03
)Obsolete
methodsUnmanagedCallersOnly
methodsCompilerFeatureRequired
methodsIEnumerable
only (SpreadElement_10
)ref struct
iterator typeref struct
typeLength
orCount
propertyObsolete
(SpreadElement_LengthObsolete
)UnmanagedCallersOnly
CompilerFeatureRequired
Extension method invocationtype inferencemethods)
ExpressionTrees
)Array.Empty<T>()
forIEnumerable<T> e = [];
(ArrayEmpty_01
)avoid heap allocation when not observable:foreach (var b in [true, false]) { ... }
__arglist
andArgIterator
usageref
safety in elementsstackalloc
elementRefSafety_Return_01
)ref (readonly)
in
TypeInference_20
)TypeInference_21
)ref (readonly)
returnref
reassignmentDirect method execution (MemberAccess_01
,_02
)fixed
statement immediately taking a pointerusing
blockReadOnlySpan<byte[]> x = ["abc"u8];
should behave likebyte[] x = "abc"u8;
!
(should produce a diagnostic)Productivity
[return: MyAttribute]
and[return: expr]
are both possibleList<int> list = [1, 2, 3];
(no extra spaces)[Method1(), Method2()]
should behave like array creation and other similar existing constructsOpen Questions
(X)[i]
cast collection literal or indexing?[a ? [b] : c]
conditional[a ? ([b]) : c]
or key-value pair[(a ? [b]) : c]
?a ? b ? [c] : d
nested indexera ? (b?[c]) : d
or nested collection literala ? (b ? ([c]) : d)
?Range[] ranges = [range1, ..e, range2];
spread or range..e
?Add()
calls?IEnumerable
and has an accessible parameterless constructor is a valid target type for[]
. Should the requirements for a collection initializer type be stronger than this?List<T>.Add(T)
rather than relying on lookup?TypeInference_40
)IAsyncEnumerable<int> e
be supported for[1, 2, await ..e]
?The text was updated successfully, but these errors were encountered: