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

Feature Request: with statement for SES (Secure EcmaScript) support #1056

Open
leotm opened this issue Jul 17, 2023 · 3 comments
Open

Feature Request: with statement for SES (Secure EcmaScript) support #1056

leotm opened this issue Jul 17, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@leotm
Copy link

leotm commented Jul 17, 2023

Problem

Continuing our convo

We have no plans to support non-strict local eval or with - unfortunately they are incompatible with our code generation strategy and bytecode instructions. It is theoretically possible to implement them on top of JS objects with the existing bytecode, but the effort would be significant and the performance truly appalling...

...FWIW, I think we might be able to add support for with. It feels wrong to completely ignore a language feature that has been with us for many years. It also feels good to pass most of test262. Plus, the implementation is interesting and will not slow everything down. But I can't promise it is high priority.

in order to introduce SES to our RN ecosystem (starting with metamask-mobile)

we can get by without local eval, but with statements are required

Solution

with statements support 🙏

Alternatives considered

Additional Context

https://github.com/facebook/hermes/blob/main/doc/Features.md#excluded-from-support

Excluded From Support

  • Symbol.unscopables (Hermes does not support with)
  • with statements

hermesengine.dev/playground

# with ([1, 2, 3]) {
#   console.log(toString()); // 1,2,3
# }

/tmp/hermes-input.js:1:1: error: invalid statement encountered.
with ([1, 2, 3]) {
^~~~~~~~~~~~~~~~~~
Emitted 1 errors. exiting.
@leotm leotm added the enhancement New feature or request label Jul 17, 2023
@leotm
Copy link
Author

leotm commented Jul 17, 2023

@tmikov noting this won't slow everything down, but not promised as high priority
do you have an update on the timeframe? and would you be happy to accept a community contribution?

keen to know more on the interesting implementation and any pointers (like given for eval in the past) to give it a try

@tmikov
Copy link
Contributor

tmikov commented Jul 19, 2023

@leotm unfortunately the answer is tricky. Ordinarily we are very happy to accept community contributions (although historically we have gotten very few, and the bar for changing the compiler is quite high).

The problem is that the current version of Hermes is frozen, except for bug fixes, while the next version, which is developed in a branch, has diverged significantly, particularly in the area of variable resolution and code generation, which is precisely where with would be handled. Worse, the next version is changing very rapidly at the moment, so it is not a very suitable target.

Even if we were to implement "with" in the frozen version, it wouldn't be portable to the next version.

Let me think about the best way to do this.

@leotm
Copy link
Author

leotm commented Aug 1, 2023

thanks again for the detailed update and porting previous issue here (i didn't spot 🙈)

happy to assist when thoughts have marinated, like with test cases covering the SES with requirement (in addition to test262)

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

No branches or pull requests

2 participants