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 IL generated for storing value in a local variable. #68

Open
ghost opened this issue Oct 17, 2020 · 0 comments
Open

Wrong IL generated for storing value in a local variable. #68

ghost opened this issue Oct 17, 2020 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 17, 2020

Source code

class Program
{
    static void Main(string[] args)
    {
        int add = Add(20, 10);
        int sub = Subtract(20, 10);
        int multiply = Multiply(20, 10);
        int divide = Divide(20, 10);
        // Issue here
        int modulo = Modulo(20, 10);
    }

    static int Add(int i, int j) => i + j;

    static int Subtract(int i, int j) => i - j;

    static int Multiply(int i, int j) => i * j;

    static int Divide(int i, int j) => i / j;

    static int Modulo(int i, int j) => i % j;
}

Steps to reproduce

  1. Compile the above source code into a DLL.
  2. Run dotnet ildasm on the DLL.

Expected IL

IL_0032: stloc.s V_4

Actual IL

IL_0032: stloc.s class V_4

Error
When running ILAsm : MSIL.il(60) : error : syntax error at token 'class' in: IL_0032: stloc.s class V_4
Works well with traditional ILDAsm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants