pike.git
/
src
/
pike_types.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/pike_types.cmod:10915:
/* Returns whether a value of type 'type' may be indexed with a value * of type 'index_type'. Returns -1 if the indexing operation is valid, * but will always fail. * The node 'n' is the node with the indexing operator. */ static int low_check_indexing(struct pike_type *type, struct pike_type *index_type, node *n) {
-
if (!type) return
1
;
+
if (!type) return
0
;
switch(type->type) { case T_OR: return low_check_indexing(type->car, index_type, n) || low_check_indexing(type->cdr, index_type, n); case T_AND: return low_check_indexing(type->car, index_type, n) && low_check_indexing(type->cdr, index_type, n);
pike.git/src/pike_types.cmod:10961:
case T_ASSIGN: case T_SCOPE: return low_check_indexing(type->cdr, index_type, n); case T_ARRAY: if(match_types(string_type_string, index_type) && low_check_indexing(type->cdr, index_type, n)) return 1; /* FALLTHRU */ case T_STRING:
-
return
match_types(int_type_string, index_type);
+
if
(!
match_types(int_type_string, index_type)
) return 0
;
+
/* FIXME: Convert max(type->car) into int(-max..max-1), and check
+
* it against the index_type.
+
*/
+
return 1;
case T_OBJECT: { struct program *p = id_to_program(CDR_TO_INT(type)); if(p) { int i = -1; /* Check against the LFUN types. */ if(n && (n->token == F_ARROW)) {
pike.git/src/pike_types.cmod:11003:
} } case T_MULTISET: case T_MAPPING: /* FIXME: Why -1 and not 0? * * - There were complaints when people got compilation errors * for indexing operations that would always fail. */
-
return match_types(type->car, index_type) ? 1 : -1;
+
if (type->car) {
+
return
=
match_types(type->car, index_type) ? 1 : -1;
+
} else {
+
/* NB: Lots of ancient code uses ([])[0] to generate UNDEFINED. */
+
return 1;
+
}
case T_FUNCTION: while ((type = type->cdr) && (type->type == T_FUNCTION)) ; if (!type) return 0; if (type->type != T_MANY) return 0; /* FALLTHRU */