bug fixed. GOTO jumped over the definition of the returned variable

This commit is contained in:
cozis
2022-04-01 19:32:29 +02:00
parent 4039d6eee2
commit 7321235fbf
+10 -4
View File
@@ -577,6 +577,7 @@ static _Bool step(Runtime *runtime, Error *error)
return 0;
Heap *heap = Runtime_GetHeap(runtime);
assert(heap != NULL);
if(Object_IsInt(top))
{
@@ -667,7 +668,7 @@ static _Bool step(Runtime *runtime, Error *error)
if(!Runtime_Push(runtime, error, res))
return 0;
break;
return 1;
}
case OPCODE_EQL:
@@ -843,7 +844,12 @@ static _Bool step(Runtime *runtime, Error *error)
// NOTE: Every local object reference is invalidated from here.
if(obj == NULL)
{
assert(error->occurred != 0);
return 0;
}
assert(error->occurred == 0);
if(!Runtime_Push(runtime, error, obj))
return 0;
@@ -1269,6 +1275,9 @@ Object *run(Runtime *runtime, Error *error, Executable *exe, int index, Object *
runtime->depth += 1;
}
// This is what the function will return.
Object *result = NULL;
// Push the initial values of the frame.
for(int i = 0; i < argc; i += 1)
if(!Runtime_Push(runtime, error, argv[i]))
@@ -1306,9 +1315,6 @@ Object *run(Runtime *runtime, Error *error, Executable *exe, int index, Object *
//printf("%2.2f%% percent.\n", Heap_GetUsagePercentage(runtime->heap));
}
// This is what the function will return.
Object *result = NULL;
// If an error occurred, we want to return NULL.
if(error->occurred == 0)
{