Skip to content

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

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions