Branch: Tag:

2014-04-08

2014-04-08 20:56:32 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Typechecker: Fix indexing of this_program.

Program types are often converted to the corresponding function
type. Make sure to allow indexing of such types if they look
like program types.

Thanks to Chris Angelico <rosuav@gmail.com> for the report.

Fixes [LysLysKOM 20764345]/[Pike mailinglist 13967].

5458:    */    return low_match_types(type->car, index_type, 0) ? 1 : -1;    +  case T_FUNCTION: +  while ((type = type->cdr) && (type->type == T_FUNCTION)) +  ; +  if (!type) return 0; +  +  /* FALL_THROUGH */ +  +  case T_MANY: +  type = type->cdr; +  if (!type || (type->type != T_OBJECT) || !type->car) +  return 0; +  /* function(... : object(is foo)) -- ie probably program(foo). */ +  +  /* FALL_THROUGH */ +     case T_INT:    case T_PROGRAM:    return !!low_match_types(string_type_string, index_type, 0);