-
Notifications
You must be signed in to change notification settings - Fork 4.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
Compiler Crash on Equality Comparison of a Tuple Casted from dynamic #76028
Comments
|
Lowering of tuple equality operators has its own code path which visits the operands element-wise, digging through conversions to locate more tuple conversions recursively, in order to compare both tuples element-wise, as the language specifies. The problem is that the path in roslyn/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_TupleBinaryOperator.cs Lines 199 to 204 in f9ccce0
I can't think of a ton of ways to observe this. But casting a dynamic to tuple is one of them. Another would be a fairly contrived case like the following: SharpLab public void M((Action, Action) dels) {
_ = ((Action, Action))(object)((Action, Action))(() => {}, () => {}) == dels;
} So the fix is figuring out how to get LocalRewriter to "visit" the conversion itself, while also preserving its behavior to dig through things element-wise and evaluate to temps. A few possibilities:
There may be more options I didn't think of. (2) feels most viable to me as a start. Tagging @jcouv for thoughts here. |
This bug is likely not a regression and I probably need more assistance in order to be able to solve it. |
Version Used: .NET 9.0.0
Steps to Reproduce:
dynamic
value to a tuple and performing an equality comparison on another tuple.Expected Behavior: The compiler compiles the code without crashes.
Actual Behavior:
The text was updated successfully, but these errors were encountered: