pike.git / src / las.cmod

version» Context lines:

pike.git/src/las.cmod:3260:   }      void fix_foreach_type(node *val_lval)   {    struct compilation *c = THIS_COMPILATION;    node *expression, *lvalues;       if (!val_lval || (val_lval->token != F_FOREACH_VAL_LVAL)) return;       fix_type_field(val_lval); +  +  if (Pike_compiler->compiler_pass != COMPILER_PASS_LAST) return; +     expression = CAR(val_lval);    lvalues = CDR(val_lval);       if (!expression || pike_types_le(expression->type, void_type_string, 0, 0)) {    yyerror("foreach(): Looping over a void expression.");    } else {    if(lvalues && lvalues->token == ':')    {    /* Check the iterator type */    struct pike_type *iterator_type;
pike.git/src/las.cmod:3303:    /* Check the index type */    struct pike_type *index_fun_type;    struct pike_type *index_type;    MAKE_CONSTANT_TYPE(index_fun_type,    tOr4(tFunc(tOr(tArray, tStr), tZero),    tFunc(tMap(tSetvar(0, tMix),    tMix), tVar(0)),    tFunc(tSet(tSetvar(1, tMix)),    tVar(1)),    tFuncArg(tSetvar(2, tObj), -  tFindLFun(tVar(2), +  tFindLFun(tOr(tVar(2), +  tGetReturn(tFindLFun(tVar(2), +  "_get_iterator"))),    "_iterator_index"))));    index_type = check_call(foreach_call_type, index_fun_type, 0);    if (!index_type) {    /* Should not happen. */    yytype_report(REPORT_ERROR,    NULL, 0, NULL, -  NULL, 0, NULL, +  NULL, 0, expression->type,    0, "Bad iterator type for index in foreach().");    } else {    if( CAR(lvalues)->type->type == PIKE_T_AUTO )    {    fix_auto_node(CAR(lvalues), index_type);    }    else if (!pike_types_le(index_type, CAR(lvalues)->type, 0, 0)) {    int level = REPORT_NOTICE;    if (!match_types(CAR(lvalues)->type, index_type)) {    level = REPORT_ERROR;    } else if (c->lex.pragmas & ID_STRICT_TYPES) {    level = REPORT_WARNING;    }    yytype_report(level, -  NULL, 0, index_type, +     NULL, 0, CAR(lvalues)->type, -  +  NULL, 0, index_type,    0, "Type mismatch for index in foreach().");    }    free_type(index_type);    }    free_type(index_fun_type);    }    if (CDR(lvalues)) {    /* Check the value type */    struct pike_type *value_fun_type;    struct pike_type *value_type;    MAKE_CONSTANT_TYPE(value_fun_type,    tOr5(tFunc(tArr(tSetvar(0, tMix)),    tVar(0)),    tFunc(tNStr(tSetvar(1, tMix)),    tVar(1)),    tFunc(tMap(tMix,tSetvar(2, tMix)),    tVar(2)),    tFunc(tMultiset, tInt1),    tFuncArg(tSetvar(3, tObj), -  tFindLFun(tVar(3), +  tFindLFun(tOr(tVar(3), +  tGetReturn(tFindLFun(tVar(3), +  "_get_iterator"))),    "_iterator_value"))));    value_type = check_call(foreach_call_type, value_fun_type, 0);    if (!value_type) {    /* Should not happen. */    yytype_report(REPORT_ERROR,    NULL, 0, NULL,    NULL, 0, NULL,    0, "Bad iterator type for value in foreach().");    } else {    if( CDR(lvalues)->type->type == PIKE_T_AUTO )
pike.git/src/las.cmod:3368:    fix_auto_node(CDR(lvalues), value_type);    }    else if (!pike_types_le(value_type, CDR(lvalues)->type, 0, 0)) {    int level = REPORT_NOTICE;    if (!match_types(CDR(lvalues)->type, value_type)) {    level = REPORT_ERROR;    } else if (c->lex.pragmas & ID_STRICT_TYPES) {    level = REPORT_WARNING;    }    yytype_report(level, -  NULL, 0, value_type, +     NULL, 0, CDR(lvalues)->type, -  +  NULL, 0, value_type,    0, "Type mismatch for value in foreach().");    }    free_type(value_type);    }    free_type(value_fun_type);    }    free_type(foreach_call_type);    } else {    /* Old-style foreach */    struct pike_type *array_zero;