Skip to content
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

Wrong decompilation of null nullable int #3181

Open
coxantohi opened this issue Mar 20, 2024 · 0 comments
Open

Wrong decompilation of null nullable int #3181

coxantohi opened this issue Mar 20, 2024 · 0 comments
Labels
Bug Decompiler The decompiler engine itself

Comments

@coxantohi
Copy link

coxantohi commented Mar 20, 2024

Input code

namespace NullForgivingOperatorNamespace
{
    public class NullForgivingOperatorClass
    {
        public void NullForgivingOperatorMethod()
        {
            int? x = null;
            string s = x?.ToString();
        }
    }
}

Decompiled code

namespace NullForgivingOperatorNamespace;

public class NullForgivingOperatorClass
{
	public void NullForgivingOperatorMethod()
	{
		string s = ((int)null?).ToString();
	}
}

the build errors are:

NullForgivingOperatorClass.cs(7,25): error CS1525: Invalid expression term ')'
NullForgivingOperatorClass.cs(7,25): error CS1003: Syntax error, ':' expected

Details

  • Product in use: ILSpy version 8.2.0.7535
  • Version in use: .NET version 6.0.28-servicing.24120.7+34a109148c7d8a2c8e6431e83e4bce5712dd8083

This issue was found when trying to write sample input code for #3180.

@coxantohi coxantohi added Bug Decompiler The decompiler engine itself labels Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Decompiler The decompiler engine itself
Projects
None yet
Development

No branches or pull requests

1 participant