-
-
Notifications
You must be signed in to change notification settings - Fork 567
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
Setting private properties causes NRE #1921
Comments
So iare there more code sample of specific cases? Ideally in c# utilizing the Engine. |
@lahma Here's a minimal repro in .NET: In normal code I don't foresee this really happening intentionally, but for arbitrary inputs to the engine this could happen intentionally or otherwise using Jint;
new Engine().Evaluate
(
"""
class A { }
new A().#nonexistent = 1;
"""
); And the produced exception:
|
Thanks, what about the different error message in different call context? |
class A {
constructor() { #nonexistent = 2; }
}
new A(); Produces the following error
|
Thanks for the repros. Now far easier to investigate 👍🏻 |
This was a bit monkey-patched as in v4 the parser actually detects these errors better instead of allowing the code to get into Jint's runtime logic. But at least the error message should now be better. |
Version used
Jint 3.1.5
Describe the bug
Setting a private property on a class in any capacity throws a NullReferenceException from native code.
To Reproduce
Expected behavior
Jint throws a managed (JavaScript) exception as it does with attempting to use other invalid properties.
Additional context
This specifically occurs when attempting to set a private property outside of a class (e.g., in a module function). Interestingly, doing it in a class function throws a different (and equally as vague) exception (though, "not found" does seem more indicative of correct behavior here-):
The text was updated successfully, but these errors were encountered: