diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2019-10-21 10:08:40 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2019-10-21 10:08:40 -0400 |
commit | ee7525251681a3c0ab38e0356bc3733adb3e6566 (patch) | |
tree | 9e2ded4a9de3823419375b1c31a7d4973279e2f3 /types.c | |
parent | d85766938a25c5c8fc32cdb83ee61b983d458318 (diff) |
run time slice at index; started compile time
Diffstat (limited to 'types.c')
-rw-r--r-- | types.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -979,13 +979,20 @@ static bool types_expr(Typer *tr, Expression *e) { err_print(e->where, "The index of an array must be a builtin numerical type."); return false; } - if (lhs_type->kind != TYPE_ARR) { - char *s = type_to_str(lhs_type); + switch (lhs_type->kind) { + case TYPE_ARR: + *t = *lhs_type->arr.of; + break; + case TYPE_SLICE: + *t = *lhs_type->slice; + break; + default: { + char *s = type_to_str(lhs_type); err_print(e->where, "Trying to take index of non-array type %s.", s); free(s); return false; } - *t = *lhs_type->arr.of; + } break; } break; } break; |