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

+= operator causing NullReferenceException when use on class property #537

Closed
rismans opened this issue Aug 31, 2018 · 1 comment
Closed

Comments

@rismans
Copy link

rismans commented Aug 31, 2018

Noticed this on the last two beta releases.

When using the += operator on a property of a .Net class, a NullReferenceException is thrown.

A brief snippet to demonstrate the issue:

    class Person { public string FirstName = "a"; }

    class Program
    {
        static void Main(string[] args)
        {
            Person p = new Person();
            
            Engine engine = new Engine();
            engine.SetValue("P", p);

            // Working
            Engine e1 = engine.Execute("P.FirstName = 'b'; ");
            Console.WriteLine(p.FirstName);

            // NullReferenceException
            Engine e2 = engine.Execute("P.FirstName += 'c'; "); // += Operator fails
            Console.WriteLine(p.FirstName);
            
            Console.ReadKey();
        }
    }
lahma added a commit to lahma/jint that referenced this issue Jun 13, 2019
@lahma
Copy link
Collaborator

lahma commented Jun 13, 2019

Thanks for reporting this, fixed via #630 .

@lahma lahma closed this as completed Jun 13, 2019
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

2 participants