pike.git / src / las.c

version» Context lines:

pike.git/src/las.c:3252:       case F_ASSIGN:    case F_ASSIGN_SELF:    if (!CAR(n) || (CAR(n)->type == void_type_string)) {    yyerror("Assigning a void expression.");    copy_pike_type(n->type, void_type_string);    } else if (!CDR(n)) {    copy_pike_type(n->type, CAR(n)->type);    } else {    /* Ensure that the type-fields are up to date. */ +  struct pike_type *t;    fix_type_field(CAR(n));    fix_type_field(CDR(n)); -  +  if( CDR(n)->type == PIKE_T_AUTO ) +  { +  /* Update to actual type. */ +  free_type( CDR(n)->type ); +  copy_pike_type( CDR(n)->type, CAR(n)->type ); +  }   #if 0    /* This test isn't sufficient, see below. */    check_node_type(CAR(n), CDR(n)->type, "Bad type in assignment.");   #else /* !0 */    if (!pike_types_le(CAR(n)->type, CDR(n)->type)) {    /* a["b"]=c and a->b=c can be valid when a is an array.    *    * FIXME: Exactly what case is the problem?    * /grubba 2005-02-15    *
pike.git/src/las.c:3539:    if (!CAR(n) || (CAR(n)->type == void_type_string)) {    yywarning("Returning a void expression. Converted to zero.");    if (!CAR(n)) {    _CAR(n) = mkintnode(0);    copy_pike_type(n->type, CAR(n)->type);    } else {    _CAR(n) = mknode(F_COMMA_EXPR, CAR(n), mkintnode(0));    copy_pike_type(n->type, CDAR(n)->type);    }    break; -  } else if(Pike_compiler->compiler_frame && -  Pike_compiler->compiler_frame->current_return_type) { +  } +  else if(Pike_compiler->compiler_frame && +  Pike_compiler->compiler_frame->current_return_type) +  {    if ((Pike_compiler->compiler_frame->current_return_type != -  void_type_string) || -  (CAR(n)->token != F_CONSTANT) || -  !SAFE_IS_ZERO(& CAR(n)->u.sval)) { -  check_node_type(CAR(n), -  Pike_compiler->compiler_frame->current_return_type, -  "Wrong return type."); +  void_type_string)) { +  struct pike_type *t = Pike_compiler->compiler_frame->current_return_type; +  +  if( t->type == PIKE_T_AUTO ) +  { +  if( t->car ) +  { +  /* Not the first one.. */ +  push_auto_typed_type( or_pike_types( t->car, CAR(n)->type, 0 ) );    } -  +  else +  { +  /* first one.. */ +  push_auto_typed_type( CAR(n)->type );    } -  +  free_type( t ); +  t = pop_type(); +  Pike_compiler->compiler_frame->current_return_type = t; +  } +  else if(CAR(n)->token != F_CONSTANT || !SAFE_IS_ZERO(&CAR(n)->u.sval)) +  check_node_type(CAR(n), t, "Wrong return type."); +  } +  }    copy_pike_type(n->type, void_type_string);    break;       case F_CASE_RANGE:    if (CDR(n) && CAR(n)) {    fix_type_field(CAR(n));    fix_type_field(CDR(n));    /* case 1 .. 2: */    if (!match_types(CAR(n)->type, CDR(n)->type)) {    if (!match_types(CAR(n)->type, int_type_string) ||