Repository navigation
Do not add duplicate jsdoc for assignment used as a declaration's initializer - #24973
Merged
Merged
Conversation
|
Nathan Shively-Sanders (@sandersn) think you mean #24963? |
Deleted user (ghost)
approved these changes
Jun 14, 2018
Member
Author
|
Yes, #24963. I blame auto-complete :) |
Member
Author
|
This should be ported to 2.9 as well. |
Member
Author
|
This is in 2.9 now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #24963
A BinaryExpression used as a declaration's initializer incorrectly gets duplicated jsdoc, which hits the assert I added to prevent such cases. The reason is that the BinaryExpression case gets hit twice: once when the node is the arrow function and the BinaryExpression is the parent, and again when the node itself is a BinaryExpression. That's because the check for assignments happens both for
nodeandnode.parent, but recurs tonode.parentboth times. The fix is to recur tonode.parent.parentwhennode.parentis a BinaryExpression.Unfortunately, putting the
isBinaryExpression(node.parent)check in the logical place also ends up recurring twice, albeit with no results the second time, which causes exponential search behaviour for deeply chained assignments likeexports.x = exports.y = ... = {}. The check was previously in the logical place, but I moved it to fix that bug (#23115).I think getJSDocCommentsAndWorker needs a serious overhaul. For now I am just fixing the bug, but I think it might be possible to do something like a simple walk up the parent chain looking for applicable (for some definition of applicable) jsdoc, stopping at some point like ExpressionStatement.