Skip to content

Commit 5f62b37

Browse files
committed
init ctor variables before superctor evaluation
1 parent e11d020 commit 5f62b37

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kscr-core/Bytecode/Method.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public override Stack Invoke(RuntimeBase vm, Stack stack, IObject? target = null
100100
throw new FatalException("Missing invocation target for non-static method " + Name);
101101
stack.StepInto(vm, SourceLocation, target, this, stack =>
102102
{
103+
for (var i = 0; i < Math.Min(Parameters.Count, args.Length); i++)
104+
vm.PutLocal(stack, Parameters[i].Name, args[i]);
103105
if (Name == ConstructorName)
104106
{
105107
// pre-handle super calls
@@ -113,8 +115,6 @@ public override Stack Invoke(RuntimeBase vm, Stack stack, IObject? target = null
113115
superCtor.Invoke(vm, stack, target, args: args.AsArray(vm, stack));
114116
}
115117
}
116-
for (var i = 0; i < Math.Min(Parameters.Count, args.Length); i++)
117-
vm.PutLocal(stack, Parameters[i].Name, args[i]);
118118
Body.Evaluate(vm, stack);
119119
if (stack.State != State.Return && Name != ConstructorName && ReturnType.Name != "void")
120120
throw new FatalException("Invalid state after method: " + stack.State);

0 commit comments

Comments
 (0)