-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
Problem with nullable types #1680
Comments
That is great news! We are really looking forward to a more complete test suite. See #829 for the list of features currently supported by the decompiler. Thank you very much for your help! |
@lambertlb In the above code, what would be the expected behavior? Using local variables in these test cases might not be a good idea, because they will get eliminated by the compiler most of the time. I am not quite sure, whether it would be better to use |
The issue seems to be only with unsigned nullable types uint and ulong. The translator works just fine with other types. Following is a small test to illustrate.
Translated code
The error above is for trying to convert -1 to uint?.
I have been trying to debug this but i get lost on the recursive plunge translations. I have used recursive plunge algorithms in the past to make compilers but they tend to get hard to follow. I normally use table lookup algorithms now. |
To understand the recursion in Looking at the translation of the And so is the right hand side: So the problem is with the
A cast |
Ah actually This problem only occurs for nullables, because ILSpy never emits a |
Normal It's also possible to improve |
As i mentioned in a previous thread, I want to contribute. I have started a comprehensive test project where i am going through every C# feature and creating tests. I have a ways to go but have found an issue dealing with nullable types. Following are a couple of examples extracted from my tests. I will continue making more tests by examining the C# specs so let me know if there is anything i can do to help.
Original code:
private void UInt64NullableTests()
{
UInt64? value = 0;
LocalAssert(~value == UInt64.MaxValue);
}
private void UInt32NullableTests()
{
UInt32? value = 0;
LocalAssert(~value == UInt32.MaxValue);
}
Converted code:
private void UInt64NullableTests()
{
LocalAssert(~new ulong?(0uL) == (ulong?)(-1));
}
private void UInt32NullableTests()
{
LocalAssert(~new uint?(0u) == (uint?)(-1));
}
The text was updated successfully, but these errors were encountered: