Replies: 0 comments 1 reply
-
I don't know if this was the reason, but one possible reason is that if you declare too few variables by mistake, you want this to be an error. And since changing the return type this way is already a breaking change, requiring the extra Also this discussion belongs on dotnet/csharplang, somebody will hopefully move it there. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Given the method signature:
we can deconstruct it like so:
But if the method's signature changes to include additional items, e.g:
then the deconstruction code now generates a compiler error (CS8132 "Can't deconstruct a tuple of '3' elements into '2' variables.").
I propose that this should be allowed by having the compiler implicitly rewrite the given expression to insert discards. That is, the compiler-generated deconstruction code effectively becomes:
and compilation succeeds.
I'm sure there's an obvious reason why this wasn't implemented, I just can't see why it is. Anyone care to enlighten me?
Beta Was this translation helpful? Give feedback.
All reactions