Branch: Tag:

2020-08-03

2020-08-03 11:10:25 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler [Typechecker]: Fixed bug in soft cast.

Soft casting of complex function types (ie not consisting only
of a chain of T_FUNCTION and T_MANY nodes) was broken.

Potential fix for a SIGSEGV in the testsuite.

6459:    push_finished_type(tmp2);    free_type(tmp2);    tmp2 = NULL; +  if ((orig_type->type == T_MANY) && +  (soft_type->type == T_MANY)) {    /* Note: Special case for the return type in case of create(). */    if (tmp) {    orig_type = tmp;
6476:    push_finished_type(tmp2);    free_type(tmp2);    tmp2 = NULL; +  } else { +  /* Some kind of complex function type. */ +  /* FIXME: Handle the case where tmp != NULL */ +  push_finished_type(orig_type); +  push_finished_type(soft_type); +  push_type(T_AND); +  }    while(array_cnt--) push_unlimited_array_type(T_ARRAY);    push_reverse_type(T_MANY);    while(loop_cnt--) push_reverse_type(T_FUNCTION);