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

Shadowing issue errorneuously reported as redefinition when using block scoping #2090

Closed
fluidsonic opened this issue Jan 9, 2015 · 2 comments
Labels

Comments

@fluidsonic
Copy link

const Set = require('some-set-package');  // Redefinition of 'Set'

Since let and const are block scoped the global variable will be left untouched.
This looks like a bug as this is shadowing, not redefinition.

I actually stumbled across this problem when overwriting Set (as node's implementation is very limited) and we can expect more such warnings in the future as the number of predefined global symbols increases.

(jshint 2.5.11)

@lukeapage
Copy link
Member

@jugglinmike this can probably be closed I think, unless @fluidsonic can provide a proper test case which doesn't work on master, but I think it should.

@jugglinmike
Copy link
Member

This is still an issue on master

gh-2090.js:

// jshint esnext: true
{
  var Proxy = null; // expected error
  const Set = null;
  let Map = null;
}
(function() {
  var Proxy = null;
  const Set = null;
  let Map = null;
}());
gh-2090.js: line 3, col 7, Redefinition of 'Proxy'.
gh-2090.js: line 4, col 9, Redefinition of 'Set'.
gh-2090.js: line 5, col 7, Redefinition of 'Map'.

lukeapage added a commit to lukeapage/jshint that referenced this issue Jun 2, 2015
lukeapage added a commit to lukeapage/jshint that referenced this issue Jun 14, 2015
lukeapage added a commit to lukeapage/jshint that referenced this issue Jun 14, 2015
Removes implied, scope and the keeping of variables on funct, by
refactoring all scope management into an expanded block scope manager
which keeps track of variable scope. As part of this it now tracks usages
and resolves them at the end of a scope so that a usage can be resolved to
a hoisted variable. This fixes jshint#2439, fixes jshint#2426, fixes jshint#2410, fixes
 jshint#2409, fixes jshint#2374, fixes jshint#2430, fixes jshint#2368, fixes jshint#2342, fixes jshint#2363,
 fixes jshint#2292, fixes jshint#2199, fixes jshint#2191, fixes jshint#2090, fixes jshint#1996, fixes
 jshint#1775, fixes jshint#1682, fixes jshint#1462, fixes jshint#1061.
lukeapage added a commit to lukeapage/jshint that referenced this issue Jun 14, 2015
Removes implied, scope and the keeping of variables on funct, by
refactoring all scope management into an expanded block scope manager
which keeps track of variable scope. As part of this it now tracks usages
and resolves them at the end of a scope so that a usage can be resolved to
a hoisted variable. This fixes jshint#2439, fixes jshint#2426, fixes jshint#2410, fixes
 jshint#2409, fixes jshint#2374, fixes jshint#2430, fixes jshint#2368, fixes jshint#2342, fixes jshint#2363,
 fixes jshint#2292, fixes jshint#2199, fixes jshint#2191, fixes jshint#2090, fixes jshint#1996, fixes
 jshint#1775, fixes jshint#1682, fixes jshint#1462, fixes jshint#1061.
jugglinmike pushed a commit to jugglinmike/jshint that referenced this issue Jun 28, 2015
Removes implied, scope and the keeping of variables on funct, by
refactoring all scope management into an expanded block scope manager
which keeps track of variable scope. As part of this it now tracks usages
and resolves them at the end of a scope so that a usage can be resolved to
a hoisted variable. This fixes jshint#2439, fixes jshint#2426, fixes jshint#2410, fixes
 jshint#2409, fixes jshint#2374, fixes jshint#2430, fixes jshint#2368, fixes jshint#2342, fixes jshint#2363,
 fixes jshint#2292, fixes jshint#2199, fixes jshint#2191, fixes jshint#2090, fixes jshint#1996, fixes
 jshint#1775, fixes jshint#1682, fixes jshint#1462, fixes jshint#1061.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants