-
Notifications
You must be signed in to change notification settings - Fork 74
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
this
value in new Function()
#20
Comments
I don't understand. It is a limitation of the shim that it does not support sloppy mode at all, so how can it fail a test of sloppy mode behavior? |
@erights Thanks for pointing this out. I have clarified. |
We're trying to reject most code that looks like it contains a direct eval expression. We should reliably reject the code above. We reject it exactly to avoid a runtime surprise, and an incompatability between code successfully running on the shim vs a real implementation. The strictness surprise still holds. For the real proposal, we should have a strict-only setting anyway. That would maintain compat with what the shim does. The shim could insist that this option be on, since the shim cannot emulate the real proposal when this option is off. |
Closing this requirement for two reasons:
|
Continuing from Agoric/realms-shim#17
As also revealed in test262, the
this
value in functions created in sloppy mode don't point to the global object. This is a current limitation of the shim.Edit: the shim documents that all code executes in strict mode. However, as with the post above, it comes as a surprise, because using
Function()
in the shim creates a function in strict mode, not a function in sloppy mode as expected. Outside of the shim, strict mode is not transitive, and code executing in sloppy mode can evaluate code in sloppy mode. Developers might not be aware of that situation when usingFunction()
oreval()
. The PR above was created to fix thethis
binding, but strict mode has many other impacts on the behavior ofFunction()
that can cause surprises, for example:We should document clearly along those lines:
However, point to note, the shim actually uses:
I am not aware of a difference in behavior, but we should also add this to the documentation.
The text was updated successfully, but these errors were encountered: