diff options
| author | gingerBill <bill@gingerbill.org> | 2022-09-22 00:47:23 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-09-22 00:47:23 +0100 |
| commit | 6fe1825db9350813a41627273268dc41983eb1f7 (patch) | |
| tree | 2607a7ae4493ee289c44d3735de61669a84aaf62 /src/check_expr.cpp | |
| parent | b15968f14061ba41fe5e800e191901c28c270bbe (diff) | |
Improve error message for slicing an enumerated array
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index dea8574da..0686d9cb2 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -9106,7 +9106,20 @@ ExprKind check_slice_expr(CheckerContext *c, Operand *o, Ast *node, Type *type_h o->type = t->RelativeSlice.slice_type; if (o->mode != Addressing_Variable) { gbString str = expr_to_string(node); - error(node, "Cannot relative slice '%s', value is not addressable", str); + error(node, "Cannot relative slice '%s', as value is not addressable", str); + gb_string_free(str); + o->mode = Addressing_Invalid; + o->expr = node; + return kind; + } + break; + + case Type_EnumeratedArray: + { + gbString str = expr_to_string(o->expr); + gbString type_str = type_to_string(o->type); + error(o->expr, "Cannot slice '%s' of type '%s', as enumerated arrays cannot be sliced", str, type_str); + gb_string_free(type_str); gb_string_free(str); o->mode = Addressing_Invalid; o->expr = node; |