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

Generators support #52

Closed
noomorph opened this issue Jul 18, 2019 · 1 comment
Closed

Generators support #52

noomorph opened this issue Jul 18, 2019 · 1 comment

Comments

@noomorph
Copy link

noomorph commented Jul 18, 2019

The documentation claims that generators are supported in Hermes, as well as for-of loops:

hermes/doc/Features.md

Lines 5 to 12 in 9cf7a40

## Supported
- Symbols (including most well-known Symbols)
- Iteration (with `[Symbol.iterator]`)
- `for..of` loops
- Destructuring assignment (with array and object "rest" properties)
- Template string literals
- Generators (`function*` and `yield`)

Consider this gist: https://gist.github.com/noomorph/f9272f1a3f4a9d1f419c2e8dadfb5fe2

As for for-of.js, the command below runs successfully, thereby confirming built-in support for that construct:

> ./hermes for-of.js
0
1
2

As for generator.js, a similar command would fail, like shown below:

> ./hermes generator.js
generator.js:1:9: error: 'identifier' expected after 'function'
function* seq(n) {
~~~~~~~~^

shell returned 2

Steps to reproduce

  1. Download Hermes binary shipped with the latest release: https://github.com/facebook/hermes/releases/tag/v0.1.0
  2. Download the gist above as ZIP.
  3. Unpack Hermes and gist to the same directory, and cd into it.
  4. Run the commands suggested above.

Expected result

I see a few options - either:

  1. It is a documentation issue. Then docs should explicitly state that support for generators is not built-in, instead, Hermes relies on a transpiler.
  2. It is a bug, and generators were meant to work without prior transpilation in Hermes.
  3. It is an incorrect issue - and I just need to add extra command-line flags to run code with generators via Hermes.

Actual result

While for-of and generators stand in the very same Supported features list side by side, I see major differences in how they are supported in Hermes. More clarity won't hurt if we bring it in.

@mhorowitz
Copy link
Contributor

This is a version skew issue. Generators are supported in master and in the initial github commit, but due to some manual steps to make the initial binary release before OSS launch, didn't make it into the v0.1.0 build. If you build from master, then generator.js should work. When we make the next binary release, for-of and generators should be equally supported. We're working on better release automation so it's less error-prone in the future. Sorry for the confusion!

facebook-github-bot pushed a commit that referenced this issue Mar 4, 2021
Summary: Pull Request resolved: facebookincubator/fbjni#52

Reviewed By: mweststrate

Differential Revision: D26815823

Pulled By: passy

fbshipit-source-id: 90c5806d087663025dc504cdb0bc90f60161220d
mganandraj pushed a commit to mganandraj/hermes that referenced this issue Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants