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

[[FIX]] Reset generator flag for each method definition #2389

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
4 participants
@arai-a
Copy link
Contributor

arai-a commented May 15, 2015

This patch fixes the handling of non-generator method after generator method.
For examle:

var a = {
  *gen() {
    yield 1;
  },
  non_gen() {
  }
};

Here, non_gen was treated as a generator function, since generator flag g
wasn't reset to false when * wasn't found before method name.

Fixes #2388

@@ -3282,6 +3282,8 @@ var JSHINT = (function() {
}
advance("*");
g = true;
} else {
g = false;

This comment has been minimized.

@caitp

caitp May 15, 2015

Member

unrelated nit, I really think we should use a different name than g for this :)

This comment has been minimized.

@arai-a

arai-a May 15, 2015

Contributor

how about isGenerator?

This comment has been minimized.

@caitp

caitp May 15, 2015

Member

yeah, something like that or isGeneratorMethod or something

' *gen() {',
' yield 1;',
' },',
' non_gen() {',

This comment has been minimized.

@caitp

caitp May 15, 2015

Member

It's not super-clear what this is testing. Do we normally report an error if we think we have a generator without a yield expression? If so, probably worth marking that in a comment, just to help reviewer-sanity =)

@caitp

This comment has been minimized.

Copy link
Member

caitp commented May 15, 2015

Otherwise, LGTM

@coveralls

This comment has been minimized.

Copy link

coveralls commented May 15, 2015

Coverage Status

Coverage increased (+0.0%) to 96.56% when pulling c808b5c on arai-a:generator-method into ab12dfb on jshint:master.

@arai-a arai-a force-pushed the arai-a:generator-method branch from c808b5c to 9c2c912 May 15, 2015

@coveralls

This comment has been minimized.

Copy link

coveralls commented May 15, 2015

Coverage Status

Coverage increased (+0.0%) to 96.56% when pulling 9c2c912 on arai-a:generator-method into ab12dfb on jshint:master.

1 similar comment
@coveralls

This comment has been minimized.

Copy link

coveralls commented May 15, 2015

Coverage Status

Coverage increased (+0.0%) to 96.56% when pulling 9c2c912 on arai-a:generator-method into ab12dfb on jshint:master.

@@ -3216,7 +3216,7 @@ var JSHINT = (function() {

(function(x) {
x.nud = function() {
var b, f, i, p, t, g, nextVal;
var b, f, i, p, t, isGeneratorMethod, nextVal;

This comment has been minimized.

@rwaldron

rwaldron May 15, 2015

Member

Declare it with a value of false

[[FIX]] Reset generator flag for each method definition
This patch fixes the handling of non-generator method after generator method.
For examle:

    var a = {
      *gen() {
        yield 1;
      },
      non_gen() {
      }
    };

Here, non_gen was treated as a generator function, since generator flag `g`
wasn't reset to false when `*` wasn't found before method name.

Fixes #2388

@arai-a arai-a force-pushed the arai-a:generator-method branch from 9c2c912 to 2c6e596 May 15, 2015

@coveralls

This comment has been minimized.

Copy link

coveralls commented May 15, 2015

Coverage Status

Coverage increased (+0.0%) to 96.56% when pulling 2c6e596 on arai-a:generator-method into ab12dfb on jshint:master.

@caitp

This comment has been minimized.

Copy link
Member

caitp commented May 15, 2015

this is good to merge, imho =)

@rwaldron

This comment has been minimized.

Copy link
Member

rwaldron commented May 15, 2015

Once it's full green, we can land

@caitp caitp closed this in 2444a04 May 15, 2015

jugglinmike added a commit to jugglinmike/jshint that referenced this pull request Jun 3, 2015

[[FIX]] Reset generator flag for each method definition
This patch fixes the handling of non-generator method after generator method.
For examle:

    var a = {
      *gen() {
        yield 1;
      },
      non_gen() {
      }
    };

Here, non_gen was treated as a generator function, since generator flag `g`
wasn't reset to false when `*` wasn't found before method name.

Closes jshint#2388
Closes jshint#2389
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment