Repository navigation
Conversation
Since the grammar update in #1141, a non-empty initializer or condition in a `for` header is a bare expression, while an empty one is still an `empty_statement`. Counting the latter made `for (;;) {}` worth two more logical lines than `for (i = 0; i < n; ++i) {}`. Re-enable the pdf.js files excluded in #1143: their snapshot differences came from the change in the shape of `for` headers, not from a parse error. Fixes #1265. Fixes #1143.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1268 +/- ##
==========================================
- Coverage 90.43% 90.37% -0.07%
==========================================
Files 62 62
Lines 16458 16365 -93
==========================================
- Hits 14884 14790 -94
- Misses 1574 1575 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #1265.
Fixes #1143.
#1143 wasn't a parse error. Since the grammar update in #1141, the initializer and condition of a
forheader are bare expressions instead ofexpression_statementnodes. So eachfor (a; b; c)now counts as one logical line instead of three, which matches C++ and Java.An empty slot is still an
empty_statement, though, and that was being counted. This madefor (;;) {}worth two more logical lines thanfor (i = 0; i < n; ++i) {}. This PR skipsempty_statementnodes whose parent is afor_statementin the JavaScript, Mozjs, TypeScript and TSXLocimplementations, and adds a test covering all four.It also removes the exclusion list from
tests/pdf_js_test.rsand regenerates the pdf.js snapshots (mozilla/rust-code-analysis-output#8). Almost all the snapshot changes are inlloc*fields. The only exception isexternal/dist/webpack.js, where Halstead and MI also change: tree-sitter-javascript now parsesimport.metaas ameta_propertynode, which isn't counted as an operand. That's another consequence of #1141, unrelated to this fix.The submodule currently points at the snapshots branch; I'll update it to the merged commit once the snapshots PR is merged.