clear out getters on new scope

pull/12780/head
Rich Harris 2 years ago
parent 1942f87ed9
commit 7f566621e1

@ -58,7 +58,21 @@ import { VariableDeclaration } from './visitors/VariableDeclaration.js';
/** @type {Visitors} */
const visitors = {
_: set_scope,
_: function set_scope(node, { next, state }) {
const scope = state.scopes.get(node);
if (scope && scope !== state.scope) {
const getters = { ...state.getters };
for (const name of scope.declarations.keys()) {
delete getters[name];
}
next({ ...state, getters, scope });
} else {
next();
}
},
AnimateDirective,
ArrowFunctionExpression,
AssignmentExpression,

@ -532,7 +532,6 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
references_within.add(id);
}
}
scopes.set(node.expression, state.scope);
// context and children are a new scope
const scope = state.scope.child();

Loading…
Cancel
Save