-
-
Notifications
You must be signed in to change notification settings - Fork 222
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 collapse with circular reference #523
Conversation
Codecov Report
@@ Coverage Diff @@
## master #523 +/- ##
==========================================
+ Coverage 83.06% 83.26% +0.19%
==========================================
Files 34 34
Lines 2539 2539
Branches 907 908 +1
==========================================
+ Hits 2109 2114 +5
+ Misses 257 254 -3
+ Partials 173 171 -2
Continue to review full report at Codecov.
|
obj.isIdentifier() && | ||
right.isIdentifier() && | ||
obj.node.name === right.node.name | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. But, this check should go into the checkReference
call which is used above so it applies the fix for all collapsers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! I'll do it to checkReference
.
@@ -44,7 +44,7 @@ class SetCollapser extends Collapser { | |||
if (args.length !== 1) { | |||
return false; | |||
} | |||
if (checkReference(args)) { | |||
if (checkReference(args[0])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should not expect an array (as Line 44), so I change to args[0]
made Set
works with this PR.
@@ -142,7 +142,7 @@ function getContiguousStatementsAndExpressions( | |||
|
|||
function getReferenceChecker(references) { | |||
// returns a function s.t. given an expr, returns true iff expr is an ancestor of a reference | |||
return expr => references.some(r => r.isDescendant(expr)); | |||
return expr => references.some(r => r.isDescendant(expr) || r === expr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better to place r === expr
first for early exit ?
This PR fix the bug for:
Will convert to:
It will get
undefined
forvar
, a ReferenceError forlet
andconst
.I catched the problem with
prop-types
module.