pike.git / src / las.c

version» Context lines:

pike.git/src/las.c:1355:    struct pike_type *result_type = NULL;       if(!n) return 0;      #ifdef PIKE_DEBUG    if (!type) {    Pike_fatal("Soft cast to no type!\n");    }   #endif /* PIKE_DEBUG */    -  if (Pike_compiler->compiler_pass == 2) { +  if (Pike_compiler->compiler_pass == 2 && type->type != PIKE_T_AUTO ) {    if (type == void_type_string) {    yywarning("Soft cast to void.");    return mknode(F_POP_VALUE, n, 0);    }       if(type==n->type) {    struct pike_string *t1 = describe_type(type);    yywarning("Soft cast to %S is a noop.", t1);    free_string(t1);    return n;
pike.git/src/las.c:3422:    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->type == PIKE_T_AUTO ) */ -  /* { */ -  /* /\* Update to actual type. *\/ */ -  /* free_type( CDR(n)->type ); */ -  /* copy_pike_type( CDR(n)->type, CAR(n)->type ); */ -  /* } */ +  if( CAR(n)->type->type == PIKE_T_AUTO ) +  { +  /* Update to actual type (assign from soft-cast to auto). */ +  free_type( CAR(n)->type ); +  copy_pike_type( CAR(n)->type, CDR(n)->type ); +  +  /* potential extension: fix general case: +  auto z; +  z = 1; +  z= 10; +  +  -> typeof(z) == int(1)|int(10) +  */ +  }   #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    *