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

Struct field : InvalidProgramException #13294

Open
pekabon opened this issue May 18, 2015 · 0 comments
Open

Struct field : InvalidProgramException #13294

pekabon opened this issue May 18, 2015 · 0 comments

Comments

@pekabon
Copy link
Contributor

pekabon commented May 18, 2015

The following program throws InvalidProgramException:

module Program
{
    public struct Point 
    {
        public X : double {get;set;}
    }

    public class TheClass
    {
        public Increment() : void { point.X += 1; } // (1)

        public point : Point;
    }


    Main() : void
    {
        def c = TheClass();
        c.Increment();

        Console.WriteLine(c.point.X);
        _ = ReadLine();
    }
}

PEVerify output

[IL]: Error: ConsoleApplication2.exe : Program+TheClass::Increment][offset 0x00000007][found value 'Program+Point'][expected address of value 'Program+Point'] Unexpected type on the stack. 1 Error(s) Verifying ConsoleApplication2.exe

Trying to change line (1) to

public Increment() : void { point.X = point.X + 1; }

result in successful program execution (and PEVerify tell all is ok), but point.X is not actually changed

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

1 participant