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

Closed
chanukov opened this Issue Jan 31, 2014 · 7 comments

Comments

Projects
None yet
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

This comment has been minimized.

Show comment
Hide comment
@rwaldron

rwaldron Jan 31, 2014

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 (

Member

rwaldron commented Jan 31, 2014

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

This comment has been minimized.

Show comment
Hide comment
@rwaldron

rwaldron Jan 31, 2014

Member

Anyway, confirmed with:

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

rwaldron commented Jan 31, 2014

Anyway, confirmed with:

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

This comment has been minimized.

Show comment
Hide comment
@chanukov

chanukov Jan 31, 2014

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

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

This comment has been minimized.

Show comment
Hide comment
@hiddentao

hiddentao Feb 21, 2014

Contributor

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

Contributor

hiddentao commented Feb 21, 2014

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

@hiddentao

This comment has been minimized.

Show comment
Hide comment
@hiddentao

hiddentao Feb 21, 2014

Contributor

Raised a pull request in #1543

Contributor

hiddentao commented Feb 21, 2014

Raised a pull request in #1543

@hiddentao hiddentao referenced this issue in waigo/waigo Feb 21, 2014

Closed

JSHint problems #3

@chanukov

This comment has been minimized.

Show comment
Hide comment

👍

@valueof

This comment has been minimized.

Show comment
Hide comment
@valueof

valueof Mar 21, 2014

Member

Merged.

Member

valueof commented Mar 21, 2014

Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment