Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

Commit 8fb88be

Browse files
Merge pull request #1773 from glimmerjs/opcode-balance
Maintain opcode stack consistency in non-interactive mode
2 parents 48c57da + 1f969b2 commit 8fb88be

File tree

1 file changed

+12
-10
lines changed
  • packages/@glimmer/runtime/lib/compiled/opcodes

1 file changed

+12
-10
lines changed

packages/@glimmer/runtime/lib/compiled/opcodes/dom.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,11 @@ APPEND_OPCODES.add(VM_CLOSE_ELEMENT_OP, (vm) => {
147147
});
148148

149149
APPEND_OPCODES.add(VM_MODIFIER_OP, (vm, { op1: handle }) => {
150+
let args = check(vm.stack.pop(), CheckArguments);
150151
if (!vm.env.isInteractive) {
151152
return;
152153
}
153-
154154
let owner = vm.getOwner();
155-
let args = check(vm.stack.pop(), CheckArguments);
156155
let definition = vm.constants.getValue<ModifierDefinition>(handle);
157156

158157
let { manager } = definition;
@@ -189,14 +188,17 @@ APPEND_OPCODES.add(VM_MODIFIER_OP, (vm, { op1: handle }) => {
189188
});
190189

191190
APPEND_OPCODES.add(VM_DYNAMIC_MODIFIER_OP, (vm) => {
191+
let { stack } = vm;
192+
let ref = check(stack.pop(), CheckReference);
193+
let args = check(stack.pop(), CheckArguments);
194+
192195
if (!vm.env.isInteractive) {
193196
return;
194197
}
195198

196-
let { stack } = vm;
197-
let ref = check(stack.pop(), CheckReference);
198-
let args = check(stack.pop(), CheckArguments).capture();
199-
let { positional: outerPositional, named: outerNamed } = args;
199+
let capturedArgs = args.capture();
200+
201+
let { positional: outerPositional, named: outerNamed } = capturedArgs;
200202

201203
let { constructing } = vm.tree();
202204
let initialOwner = vm.getOwner();
@@ -223,12 +225,12 @@ APPEND_OPCODES.add(VM_DYNAMIC_MODIFIER_OP, (vm) => {
223225
owner = curriedOwner;
224226

225227
if (positional !== undefined) {
226-
args.positional = positional.concat(outerPositional) as CapturedPositionalArguments;
228+
capturedArgs.positional = positional.concat(outerPositional) as CapturedPositionalArguments;
227229
}
228230

229231
if (named !== undefined) {
230232
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
231-
args.named = Object.assign({}, ...named, outerNamed);
233+
capturedArgs.named = Object.assign({}, ...named, outerNamed);
232234
}
233235
} else {
234236
hostDefinition = value;
@@ -261,7 +263,7 @@ APPEND_OPCODES.add(VM_DYNAMIC_MODIFIER_OP, (vm) => {
261263
owner,
262264
expect(constructing, 'BUG: ElementModifier could not find the element it applies to'),
263265
definition.state,
264-
args
266+
capturedArgs
265267
);
266268

267269
return {
@@ -280,7 +282,7 @@ APPEND_OPCODES.add(VM_DYNAMIC_MODIFIER_OP, (vm) => {
280282
'BUG: ElementModifier could not find operations to append to'
281283
);
282284

283-
operations.addModifier(vm, instance, args);
285+
operations.addModifier(vm, instance, capturedArgs);
284286

285287
tag = instance.manager.getTag(instance.state);
286288

0 commit comments

Comments
 (0)