Skip to content
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 hasShadowedGlobals check to properly ignore top-level declarations #367

Merged
merged 1 commit into from
Dec 24, 2018

Conversation

alangpierce
Copy link
Owner

We'll want top-level declaration detection for #228 anyway, and
hasShadowedGlobals was buggy because it was treating export declarations as
shadowing themselves, so this adds some bookkeeping so we know when a
declaration is top-level or not.

This doesn't affect correctness, it was just an optimization that wasn't kicking
in when it was supposed to.

Tracking scope depth throughout the parser is a little scary and adds another
field to the state, so there may be a way to improve it in the future, but it
certainly should work for now.

We'll want top-level declaration detection for #228 anyway, and
hasShadowedGlobals was buggy because it was treating export declarations as
shadowing themselves, so this adds some bookkeeping so we know when a
declaration is top-level or not.

This doesn't affect correctness, it was just an optimization that wasn't kicking
in when it was supposed to.

Tracking scope depth throughout the parser is a little scary and adds another
field to the state, so there may be a way to improve it in the future, but it
certainly should work for now.
@codecov-io
Copy link

Codecov Report

Merging #367 into master will increase coverage by 0.12%.
The diff coverage is 95.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #367      +/-   ##
==========================================
+ Coverage   79.47%   79.59%   +0.12%     
==========================================
  Files          44       44              
  Lines        5066     5101      +35     
  Branches     1131     1133       +2     
==========================================
+ Hits         4026     4060      +34     
- Misses        741      742       +1     
  Partials      299      299
Impacted Files Coverage Δ
src/identifyShadowedGlobals.ts 87.8% <ø> (+0.3%) ⬆️
src/parser/traverser/expression.ts 82.92% <100%> (+0.45%) ⬆️
src/transformers/CJSImportTransformer.ts 92.02% <100%> (-0.03%) ⬇️
src/parser/tokenizer/state.ts 100% <100%> (ø) ⬆️
src/parser/plugins/flow.ts 62.21% <100%> (+0.07%) ⬆️
src/parser/traverser/lval.ts 97.5% <100%> (+0.06%) ⬆️
src/parser/tokenizer/index.ts 72.68% <100%> (+0.59%) ⬆️
src/parser/traverser/statement.ts 80.28% <88.23%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e476734...3b2de13. Read the comment docs.

@alangpierce alangpierce merged commit b7f3650 into master Dec 24, 2018
@alangpierce alangpierce deleted the fix-has-shadowed-globals branch December 24, 2018 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants