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

An issue with "new Function" #151

Closed
wailovet opened this issue May 23, 2020 · 2 comments
Closed

An issue with "new Function" #151

wailovet opened this issue May 23, 2020 · 2 comments
Labels

Comments

@wailovet
Copy link

I found this code does not work when I use it

    a = function () {
        this.m2 = (new Function("with(this){m(c)}"))
    };
    a.prototype.c = "hello";
    a.prototype.m = function () {
        console.log("c:", this.c)
    };
    b = new a();
    b.m2()

chrome result : "c: hello"
goja result : "c: undefined"

@dop251 dop251 closed this as completed in e92122c May 23, 2020
@dop251 dop251 added the bug label May 23, 2020
dop251 added a commit that referenced this issue May 23, 2020
@dop251
Copy link
Owner

dop251 commented May 23, 2020

Thanks for reporting. It should now be fixed, but I would not use with unless it's some legacy code you cannot or do not want to touch. Use strict mode whenever possible.

@wailovet
Copy link
Author

Thanks for reporting. It should now be fixed, but I would not use with unless it's some legacy code you cannot or do not want to touch. Use strict mode whenever possible.

Thanks, this error comes from an extension library and I can't modify it

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

No branches or pull requests

2 participants