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.
parent 0bc05a21
......@@ -6459,23 +6459,32 @@ struct pike_type *soft_cast(struct pike_type *soft_type,
push_finished_type(tmp2);
free_type(tmp2);
tmp2 = NULL;
/* Note: Special case for the return type in case of create(). */
if (tmp) {
orig_type = tmp;
} else {
orig_type = orig_type->cdr;
}
if (tmp3) {
soft_type = tmp3;
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;
} else {
orig_type = orig_type->cdr;
}
if (tmp3) {
soft_type = tmp3;
} else {
soft_type = soft_type->cdr;
}
if (!(tmp2 = soft_cast(soft_type, orig_type, flags))) {
goto function_cast_fail;
}
push_finished_type(tmp2);
free_type(tmp2);
tmp2 = NULL;
} else {
soft_type = soft_type->cdr;
/* 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);
}
if (!(tmp2 = soft_cast(soft_type, orig_type, flags))) {
goto function_cast_fail;
}
push_finished_type(tmp2);
free_type(tmp2);
tmp2 = NULL;
while(array_cnt--) push_unlimited_array_type(T_ARRAY);
push_reverse_type(T_MANY);
while(loop_cnt--) push_reverse_type(T_FUNCTION);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment