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

Remove variable shadowing from the JavaScript files in the src/core/ folder #11738

Merged
merged 1 commit into from
Mar 24, 2020

Conversation

Snuffleupagus
Copy link
Collaborator

This is part of a series of patches that will try to split PR #11566 into smaller chunks, to make reviewing more feasible.

Once all the code has been fixed, we'll be able to eventually enable the ESLint no-shadow rule; see https://eslint.org/docs/rules/no-shadow

…` folder

*This is part of a series of patches that will try to split PR 11566 into smaller chunks, to make reviewing more feasible.*

Once all the code has been fixed, we'll be able to eventually enable the ESLint no-shadow rule; see https://eslint.org/docs/rules/no-shadow
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.215.176.217:8877/8ba08843d9ae3cd/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/2961a36c685237f/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/2961a36c685237f/output.txt

Total script time: 19.52 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/2961a36c685237f/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.215.176.217:8877/8ba08843d9ae3cd/output.txt

Total script time: 25.15 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.215.176.217:8877/8ba08843d9ae3cd/reftest-analyzer.html#web=eq.log

@@ -1409,7 +1408,7 @@ var Font = (function FontClosure() {
tables["post"] = null;

for (let i = 0; i < numTables; i++) {
const table = readTableEntry(font);
const table = readTableEntry(file);
Copy link
Contributor

@timvandermeij timvandermeij Mar 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one actually looks like it caused a bug since we always read the entry for the font variable of the upper scope here and not for the given file parameter, and I found a call-site that actually passes a different value than font here. If I'm not missing anything here, I'm surprised we haven't seen any problems because of it, but it would show that de-shadowing is a good thing!

Copy link
Collaborator Author

@Snuffleupagus Snuffleupagus Mar 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this case is absolutely confusing!

The only reason that this hasn't caused any bugs is that these properties are Objects (in this case instanceof Stream), and those are essentially passed by reference rather than value in JavaScript (the names font/file/... thus point to the same data).

@timvandermeij timvandermeij merged commit f851053 into mozilla:master Mar 24, 2020
@timvandermeij
Copy link
Contributor

Thanks a lot!

@Snuffleupagus Snuffleupagus deleted the no-shadow-src-core branch March 24, 2020 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants