Skip to content

Commit

Permalink
use find_owner instead
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhauhau committed Oct 13, 2022
1 parent 1cdf3e0 commit 24d112d
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/compiler/compile/nodes/shared/Expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Block from '../../render_dom/Block';
import is_dynamic from '../../render_dom/wrappers/shared/is_dynamic';
import { b } from 'code-red';
import { invalidate } from '../../render_dom/invalidate';
import { Node, FunctionExpression, Identifier } from 'estree';
import { Node, FunctionExpression, Identifier, VariableDeclarator } from 'estree';
import { INode } from '../interfaces';
import { is_reserved_keyword } from '../../utils/reserved_keywords';
import replace_object from '../../utils/replace_object';
Expand Down Expand Up @@ -153,16 +153,7 @@ export default class Expression {
variable[deep ? 'mutated' : 'reassigned'] = true;
}

let current_scope = scope;
let declaration;

while (current_scope) {
if (current_scope.declarations.has(name)) {
declaration = current_scope.declarations.get(name);
break;
}
current_scope = current_scope.parent;
}
const declaration: any = scope.find_owner(name)?.declarations.get(name);

if (declaration) {
if (declaration.kind === 'const' && !deep) {
Expand Down

0 comments on commit 24d112d

Please sign in to comment.