Branch: Tag:

2020-01-23

2020-01-23 15:32:18 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler [Typechecker]: Improved type checking.

Fixed issue where constant expressions after evaluation sometimes
got a partially weaker type. Eg: The expression

({ 0, 1, 2, 3 })

gets the type array(int(4bit)) from evaluating the type, but
the type array(4: int) from generating a type from the value.
The code generator now adds a soft-cast to the original type,
causing the resulting type to be array(4: int(4bit)).

Fixes testsuite failures for undumped pikes from eg SSL.Context.

6130:    } else {    push_finished_type(zero_type_string);    } -  push_unlimited_array_type(T_ARRAY); +  if (orig_type->type == T_ARRAY) { +  if ((tmp2 = soft_cast(soft_type->car, orig_type->car, flags))) { +  push_finished_type(tmp2); +  } else { +  push_finished_type(orig_type->car); +  } +  } else { +  push_finished_type(soft_type->car); +  } +  push_type(T_ARRAY);    res = pop_unfinished_type();    break;    case T_STRING: -  res = soft_cast(soft_type->cdr, orig_type->cdr, flags); -  if (!res) return NULL; +  tmp = soft_cast(soft_type->cdr, orig_type->cdr, flags); +  if (!tmp) return NULL;    type_stack_mark(); -  push_finished_type(res); -  free_type(res); -  push_unlimited_array_type(T_STRING); +  push_finished_type(tmp); +  if (orig_type->type == T_STRING) { +  if ((tmp2 = soft_cast(soft_type->car, orig_type->car, flags))) { +  push_finished_type(tmp2); +  } else { +  push_finished_type(orig_type->car); +  } +  } else { +  push_finished_type(soft_type->car); +  } +  push_type(T_STRING);    res = pop_unfinished_type();    break;    case T_INT: