-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Target-typed new can be passed in implicit-typed array #3796
Comments
We could consider target-typing implicit arrays as a fallback if the type of it cannot be determined based on its elements. |
Duplicate of #2701. I'm going to close this out. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider the code in C# 9:
I think that all four cases should be okay, but in fact, Roslyn throws a syntax error CS0826 (No best type found for implicitly-typed array) for the new expression of
z1
. The reason why I thinkz1
is okay is thatA
is astruct
, sonew[]
meansnew A[]
as the only possibility. Therefore, the inner expressionnew()
should stand fornew A()
.The text was updated successfully, but these errors were encountered: