Branch: Tag:

2022-03-18

2022-03-18 13:05:26 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler [Typechecker]: Fix type for deep automap expressions.

Fixes the type for expressions like

({ ({ 1, 2 }), ({ 3,4 }) })[*][*] + 10;

Also updated las.cmod::is_automap_arg_list() to return the automap depth.

Fixes some testsuite failures.

713:    {    default: return 0;    case F_ARG_LIST: -  return is_automap_arg_list(CAR(n)) || -  is_automap_arg_list(CDR(n)); +  { +  int car_depth = is_automap_arg_list(CAR(n)); +  int cdr_depth = is_automap_arg_list(CDR(n)); +  if (car_depth > cdr_depth) return car_depth; +  return cdr_depth; +  }    -  case F_AUTO_MAP_MARKER: return 1; +  case F_AUTO_MAP_MARKER: +  { +  int depth = 0; +  while (n && (n->token == F_AUTO_MAP_MARKER)) { +  depth++; +  n = CAR(n);    } -  +  return depth;    } -  +  } + }      static int apply_opt_flags_for_ref(struct program *prog, int fun);   
4113:    free_type(f);    if(n->token == F_AUTO_MAP)    { +  int depth;    type_stack_mark();    push_finished_type(n->type); -  +  for (depth = is_automap_arg_list(CDR(n)); depth > 0; depth--) {    push_unlimited_array_type(T_ARRAY); -  +  }    free_type(n->type);    n->type = pop_unfinished_type();    }