fix an issue where function call args were being passed backwards

This commit is contained in:
2026-05-31 20:47:22 +10:00
parent deb2a16f94
commit 2f54859ddc
2 changed files with 5 additions and 5 deletions

View File

@@ -1,12 +1,12 @@
struct Foo {
int x
init() {
self.x = 123
init(int x) {
self.x = x
}
}
func main() -> int {
Foo x = new Foo()
Foo x = new Foo(4)
return x.x
}

View File

@@ -132,8 +132,8 @@ void callFunction(CometVM* vm, CometSerializedFunc* function) {
callFrame->sp = 0;
callFrame->funcName = function->name;
for (size_t i = 0; i < function->numArgs; i++) {
callFrame->args[i] = pop(vm);
for (size_t i = function->numArgs; i > 0; i--) {
callFrame->args[i - 1] = pop(vm);
}
vm->callStack[vm->callIdx] = callFrame;