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

Weird error message when calling yield from a standard function #6693

Closed
babel-bot opened this issue May 18, 2017 · 3 comments
Closed

Weird error message when calling yield from a standard function #6693

babel-bot opened this issue May 18, 2017 · 3 comments
Labels
imported outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser

Comments

@babel-bot
Copy link
Collaborator

Issue originally reported by @msageryd in babel/babylon#530

I made the mistake of calling yield from a non-generator function. Actually an anonymous function. I would probably have understood my mistake sooner if I'd got a better error message.

It would be great with a better error message so the next generator-newbie doesn't have to struggle as much :)

I got "SyntaxError: yield is a reserved word".

Here is the code that got me the error:

function* saveUnsavedJournalItemsToServer() {
  const journalItemsToSave = yield select(selectCompletedUnsavedJournalItems);
  journalItemsToSave.map(journalItem => {
    yield fork(saveJournalItemToServer, journalItem);
  }); 
}

Here is the complete output.

journalSagas.js: SyntaxError: yield is a reserved word (177:4)
  175 |
  176 |   journalItemsToSave.map(journalItem => {
> 177 |     yield fork(saveJournalItemToServer, journalItem);
      |     ^
  178 |   });
  179 | }
  180 |
@babel-bot
Copy link
Collaborator Author

Comment originally made by @hzoo

This is a similar issue to babel/babylon#113 (await in a non async function)

@xtuc
Copy link
Member

xtuc commented Nov 6, 2018

Is this still the case or can we close it?

@msageryd
Copy link

msageryd commented Nov 6, 2018

To me it's not an issue, since I've learned my lesson. I can't try this out right now. The "issue" is just a heads-up, go ahead and close it if you don't want it in open issues.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Feb 21, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
imported outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser
Projects
None yet
Development

No branches or pull requests

4 participants