Feature Request: `with` statement for SES (Secure EcmaScript) support
- Dominant language
- JavaScript
- Stars
- 11.3k
- Forks
- 859
- Avg merge
- 1h 30m
- Merged PRs (30d)
- 3
Description
## Problem
Continuing our [convo](https://github.com/facebook/hermes/issues/957#issuecomment-1561914135)
- https://github.com/facebook/hermes/issues/957
> 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](https://github.com/endojs/endo/tree/master/packages/ses) to our RN ecosystem (starting with [metamask-mobile](https://github.com/MetaMask/metamask-mobile))
we can get by without _local eval_, but `with` statements are [required](https://github.com/facebook/hermes/issues/957#issuecomment-1560267961)
## Solution
`with` statements support 🙏
Alternatives considered
- _facebook/hermes_ community contribution: `with` statements
- more detailed in https://github.com/facebook/hermes/issues/957
- https://github.com/endojs/endo/issues/1561
## 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
```console
# 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.
```
Contributor guide
Assessment
This issue has not been assessed yet.