Fix PathHoister hoisting before a same-scope variable declaration.

Seems we didn't have tests running for this very simple case.

Also fixes #5520
This commit is contained in:
Samuel Reed
2017-05-01 15:22:26 -05:00
committed by Logan Smyth
parent 526a7d20ef
commit c307bbb3a9
8 changed files with 59 additions and 4 deletions

View File

@@ -99,11 +99,15 @@ export default class PathHoister {
const binding = this.bindings[name];
// allow parameter references
if (binding.kind === "param") continue;
// allow parameter references and expressions in params (like destructuring rest)
if (binding.kind === "param" || binding.path.parentKey === "params") continue;
// if this binding appears after our attachment point, then we move after it.
if (this.getAttachmentParentForPath(binding.path).key > path.key) {
// For each binding, get its attachment parent. This gives us an idea of where we might
// introduce conflicts.
const bindingParentPath = this.getAttachmentParentForPath(binding.path);
// If the binding's attachment appears at or after our attachment point, then we move after it.
if (bindingParentPath.key >= path.key) {
this.attachAfter = true;
path = binding.path;