mirror of
https://github.com/odin-lang/Odin.git
synced 2026-10-09 06:12:05 -04:00
Improve error message for constant indexing
This commit is contained in:
1 file changed
+2
-2
+2
-2
@@ -12209,9 +12209,9 @@ gb_internal ExprKind check_index_expr(CheckerContext *c, Operand *o, Ast *node,
|
||||
if (index < 0) {
|
||||
ERROR_BLOCK();
|
||||
gbString str = expr_to_string(o->expr);
|
||||
error(o->expr, "Cannot index a constant '%s'", str);
|
||||
error(o->expr, "Cannot index a constant '%s' with a variable index", str);
|
||||
if (!build_context.terse_errors) {
|
||||
error_line("\tSuggestion: store the constant into a variable in order to index it with a variable index\n");
|
||||
error_line("\tSuggestion: store the constant into a variable or index it with a constant\n");
|
||||
}
|
||||
gb_string_free(str);
|
||||
o->mode = Addressing_Invalid;
|
||||
|
||||
Reference in new issue
Block a user