Skip to content

Commit

Permalink
fix bug of "empty when body in case" case
Browse files Browse the repository at this point in the history
  • Loading branch information
hasumikin committed Mar 22, 2021
1 parent d4610a8 commit 7de4a29
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,16 @@ void gen_case(Scope *scope, Node *node)
/* content */
for (int j = 0; j < args_count; j++)
Scope_backpatchJmpLabel(label_true_array[j], scope->vm_code_size);
codegen(scope, case_body->cons.cdr->cons.car);
{ /* inside when */
int32_t current_vm_code_size = scope->vm_code_size;
codegen(scope, case_body->cons.cdr->cons.car);
/* if code was empty */
if (current_vm_code_size == scope->vm_code_size) {
Scope_pushCode(OP_LOADNIL);
Scope_pushCode(scope->sp);
Scope_push(scope);
}
}
Scope_pushCode(OP_JMP);
label_end_array[i++] = Scope_reserveJmpLabel(scope);
/* next case */
Expand Down

0 comments on commit 7de4a29

Please sign in to comment.