@babel/traverse 8.0.0-alpha.16 → 8.0.0-alpha.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -289,7 +289,7 @@ function verify$1(visitor) {
289
289
  }
290
290
  if (shouldIgnoreKey(nodeType)) continue;
291
291
  if (!TYPES.includes(nodeType)) {
292
- throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"8.0.0-alpha.16"}`);
292
+ throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"8.0.0-alpha.17"}`);
293
293
  }
294
294
  const visitors = visitor[nodeType];
295
295
  if (typeof visitors === "object") {
@@ -2794,6 +2794,22 @@ function _evaluate(path, state) {
2794
2794
  deopt(binding.path, state);
2795
2795
  return;
2796
2796
  }
2797
+ const bindingPathScope = binding.path.scope;
2798
+ if (binding.kind === "var" && bindingPathScope !== binding.scope) {
2799
+ let hasUnsafeBlock = !bindingPathScope.path.parentPath.isBlockStatement();
2800
+ for (let scope = bindingPathScope.parent; scope; scope = scope.parent) {
2801
+ if (scope === path.scope) {
2802
+ if (hasUnsafeBlock) {
2803
+ deopt(binding.path, state);
2804
+ return;
2805
+ }
2806
+ break;
2807
+ }
2808
+ if (scope.path.parentPath?.isBlockStatement()) {
2809
+ hasUnsafeBlock = true;
2810
+ }
2811
+ }
2812
+ }
2797
2813
  if (binding.hasValue) {
2798
2814
  return binding.value;
2799
2815
  }