mirror of
https://github.com/odin-lang/Odin.git
synced 2026-05-25 13:18:14 +00:00
for &e, i in array and for k, &v in map (alternative to passing the iterable by pointer)
This commit is contained in:
@@ -2273,7 +2273,15 @@ gb_internal void check_unary_expr(CheckerContext *c, Operand *o, Token op, Ast *
|
||||
defer (end_error_block());
|
||||
error(op, "Cannot take the pointer address of '%s'", str);
|
||||
if (e != nullptr && (e->flags & EntityFlag_ForValue) != 0) {
|
||||
error_line("\tSuggestion: Did you want to pass the iterable value to the for statement by pointer to get addressable semantics?\n");
|
||||
Type *parent_type = type_deref(e->Variable.for_loop_parent_type);
|
||||
|
||||
if (parent_type != nullptr && is_type_string(parent_type)) {
|
||||
error_line("\tSuggestion: Iterating over a string produces an intermediate 'rune' value which cannot be addressed.\n");
|
||||
} else if (parent_type != nullptr && is_type_tuple(parent_type)) {
|
||||
error_line("\tSuggestion: Iterating over a procedure does not produce values which are addressable.\n");
|
||||
} else {
|
||||
error_line("\tSuggestion: Did you want to pass the iterable value to the for statement by pointer to get addressable semantics?\n");
|
||||
}
|
||||
}
|
||||
if (e != nullptr && (e->flags & EntityFlag_SwitchValue) != 0) {
|
||||
error_line("\tSuggestion: Did you want to pass the value to the switch statement by pointer to get addressable semantics?\n");
|
||||
|
||||
Reference in New Issue
Block a user