Skip to content

Loading…

yield statements within a catch statement should not cause a error #1505

Closed
chanukov opened this Issue · 7 comments

4 participants

@chanukov
function * () {
  try {
      yield dosomething();
    } catch (err) {
      yield dosomethingelse();
  }
}

results in jshint telling me : A yield statement shall be within a generator function (with syntax: function*)
Since both try and catch are inside a generator function this error should not be given.

@rwaldron
JSHint member

I'm guessing that's not the entire piece of code? If it is, then it's a syntax error anyway, because it's missing an identifier between * and (

@rwaldron
JSHint member

Anyway, confirmed with:

function * gen() {
  try {
    yield 1;
  } catch (err) {
    yield 2;
  }
}
@chanukov

sorry obviously i was using sudo code, to demonstrate an actual thing that i do in my code, which works, just gives me jshint errors

@hiddentao

Just hit this problem myself. yield inside the catch causing problems for jshint.

@hiddentao hiddentao added a commit to hiddentao/jshint that referenced this issue
@hiddentao hiddentao Don't throw an error when yield statement used within a catch block i…
…nside a generator function.

See jshint/jshint#1505
85795c2
@hiddentao

Raised a pull request in #1543

@hiddentao hiddentao referenced this issue in waigo/waigo
Open

JSHint problems #3

@valueof
JSHint member

Merged.

@valueof valueof closed this
@jugglinmike jugglinmike added a commit to jugglinmike/jshint that referenced this issue
@hiddentao hiddentao Don't throw an error when yield statement used within a catch block i…
…nside a generator function.

See jshint/jshint#1505
5a03535
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.