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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user