diff options
| author | gingerBill <bill@gingerbill.org> | 2020-01-18 12:09:26 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-01-18 12:09:26 +0000 |
| commit | cd43f4c94c41bbf8e0668591c89f3ac9bde1871b (patch) | |
| tree | 9db96c7e6809d99679a7103e6603def2cc371022 /src/check_expr.cpp | |
| parent | 23ff98dea0fa95abac9090620830530790ecbce4 (diff) | |
Add suggestions for indexing constant values with a variable index
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 37babf91a..b854a693b 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -8874,6 +8874,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type if (index < 0) { gbString str = expr_to_string(o->expr); error(o->expr, "Cannot index a constant '%s'", str); + error_line("\tSuggestion: store the constant into a variable in order to index it with a variable index\n"); gb_string_free(str); o->mode = Addressing_Invalid; o->expr = node; @@ -9009,6 +9010,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type if (!all_constant) { gbString str = expr_to_string(o->expr); error(o->expr, "Cannot slice '%s' with non-constant indices", str); + error_line("\tSuggestion: store the constant into a variable in order to index it with a variable index\n"); gb_string_free(str); o->mode = Addressing_Value; // NOTE(bill): Keep subsequent values going without erring o->expr = node; |