fixed assertion expressions in run_switch()

This commit is contained in:
2025-06-18 23:52:25 +09:00
parent fac4aa7af5
commit 50d9b15c20

View File

@ -2399,9 +2399,10 @@ static int run_switch (hawk_rtx_t* rtx, hawk_nde_switch_t* nde)
int eval_true = 0; int eval_true = 0;
int ret = 0; int ret = 0;
/* the test expression for the if statement cannot have /* the expression for the switch statement cannot have
* chained expressions. this should not be allowed by the * chained expressions. this should not be allowed by the
* parser first of all */ * parser first of all */
HAWK_ASSERT(nde->type == HAWK_NDE_SWITCH);
HAWK_ASSERT(nde->test->next == HAWK_NULL); HAWK_ASSERT(nde->test->next == HAWK_NULL);
test = eval_expression(rtx, nde->test); test = eval_expression(rtx, nde->test);
@ -2409,9 +2410,10 @@ static int run_switch (hawk_rtx_t* rtx, hawk_nde_switch_t* nde)
hawk_rtx_refupval(rtx, test); hawk_rtx_refupval(rtx, test);
HAWK_ASSERT(nde->type == HAWK_NDE_CASE);
case_part = (hawk_nde_case_t*)nde->case_part; case_part = (hawk_nde_case_t*)nde->case_part;
default_part = (hawk_nde_case_t*)nde->default_part; default_part = (hawk_nde_case_t*)nde->default_part;
HAWK_ASSERT(case_part->type == HAWK_NDE_CASE);
HAWK_ASSERT(default_part->type == HAWK_NDE_CASE);
while (case_part) while (case_part)
{ {