diff --git a/packages/@glimmer/runtime/lib/compiled/opcodes/vm.ts b/packages/@glimmer/runtime/lib/compiled/opcodes/vm.ts index ef38318b66..98d17fb808 100644 --- a/packages/@glimmer/runtime/lib/compiled/opcodes/vm.ts +++ b/packages/@glimmer/runtime/lib/compiled/opcodes/vm.ts @@ -139,7 +139,8 @@ APPEND_OPCODES.add(Op.InvokeYield, vm => { // To balance the pop{Frame,Scope} vm.pushFrame(); - vm.pushCallerScope(); + let blockScope = vm.scope().getCallerScope()!; + vm.pushScope(blockScope); return; } @@ -147,7 +148,13 @@ APPEND_OPCODES.add(Op.InvokeYield, vm => { let locals = table.parameters; let localsCount = locals.length; - vm.pushCallerScope(localsCount > 0); + { + let blockScope = vm.scope().getCallerScope()!; + if (localsCount > 0) { + blockScope = blockScope.child(); + } + vm.pushScope(blockScope); + } let scope = vm.scope(); diff --git a/packages/@glimmer/runtime/lib/vm/append.ts b/packages/@glimmer/runtime/lib/vm/append.ts index 2a45c6ec81..dfa81d1fc7 100644 --- a/packages/@glimmer/runtime/lib/vm/append.ts +++ b/packages/@glimmer/runtime/lib/vm/append.ts @@ -372,11 +372,6 @@ export default class VM implements PublicVM { this.scopeStack.push(this.scope().child()); } - pushCallerScope(childScope = false) { - let callerScope = expect(this.scope().getCallerScope(), 'pushCallerScope is called when a caller scope is present'); - this.scopeStack.push(childScope ? callerScope.child() : callerScope); - } - pushDynamicScope(): DynamicScope { let child = this.dynamicScope().child(); this.dynamicScopeStack.push(child); @@ -390,6 +385,10 @@ export default class VM implements PublicVM { return scope; } + pushScope(scope: Scope) { + this.scopeStack.push(scope); + } + popScope() { this.scopeStack.pop(); }