Branch: Tag:

2015-09-26

2015-09-26 11:44:31 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Type-checker: Reduced warnings in strict types mode.

Don't complain in strict types mode when eg a

function(int(..0):X)|function(int(0..):Y)

is called with an int.

This change makes it possible to strengthen the types for several of
the integer operators without getting lots of erroneous warnings.

6947:    , 0   #endif    ))) { +  struct pike_type *tmp2; +  if (!(flags & CALL_STRICT) || (arg_type->type != T_INT) || +  (CAR_TO_INT(arg_type) >= 0) || (CDR_TO_INT(arg_type) <= 0)) {    return NULL;    } -  +  /* KLUDGE: Special case for integers spanning zero. +  * +  * Try splitting the argument at zero. The proper fix would be +  * to split at all the integer range limits for the first +  * declared argument to the function. +  * +  * Test the most likely problematic range first (ie negative). +  */ +  type_stack_mark(); +  push_int_type(CAR_TO_INT(arg_type), -1); +  tmp2 = pop_unfinished_type(); +  if (!(tmp = lower_new_check_call(fun_type, tmp2, +  flags & ~CALL_WEAK_VOID, sval + #ifdef PIKE_TYPE_DEBUG +  , 0 + #endif +  ))) { +  free_type(tmp2); +  return NULL; +  } +  free_type(tmp2); +  +  type_stack_mark(); +  push_finished_type(tmp); +  free_type(tmp); +  +  /* Then the positive range. */ +  type_stack_mark(); +  push_int_type(1, CDR_TO_INT(arg_type)); +  tmp2 = pop_unfinished_type(); +  if (!(tmp = lower_new_check_call(fun_type, tmp2, +  flags & ~CALL_WEAK_VOID, sval + #ifdef PIKE_TYPE_DEBUG +  , 0 + #endif +  ))) { +  free_type(tmp2); +  free_type(pop_unfinished_type()); +  return NULL; +  } +  free_type(tmp2); +  +  push_finished_type(tmp); +  free_type(tmp); +  +  /* NB: Zero always succeeds. */ +  push_type(T_OR); +  tmp = pop_unfinished_type(); +  }    return tmp;   }