aboutsummaryrefslogtreecommitdiff
path: root/src/check_stmt.cpp
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2020-12-18 14:19:03 +0100
committerGitHub <noreply@github.com>2020-12-18 14:19:03 +0100
commitbd6ead32f8d05a9662c7fa6fde867b71da0e79c9 (patch)
treee610f06a230cca9d89bf075ec55e520dae83ad8e /src/check_stmt.cpp
parent934809397f1f5f567c0ec668de72d2ac28e85f74 (diff)
parent3558848da818dc330d139ff5d756bb9b9498b1d4 (diff)
Merge pull request #1 from odin-lang/master
update from master
Diffstat (limited to 'src/check_stmt.cpp')
-rw-r--r--src/check_stmt.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp
index 8a41dd12b..117872848 100644
--- a/src/check_stmt.cpp
+++ b/src/check_stmt.cpp
@@ -1803,9 +1803,19 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) {
if (val0 == nullptr) {
gbString s = expr_to_string(operand.expr);
gbString t = type_to_string(operand.type);
+ defer (gb_string_free(s));
+ defer (gb_string_free(t));
+
error(operand.expr, "Cannot iterate over '%s' of type '%s'", s, t);
- gb_string_free(t);
- gb_string_free(s);
+
+ if (rs->val0 != nullptr && rs->val1 == nullptr) {
+ if (is_type_map(operand.type) || is_type_bit_set(operand.type)) {
+ gbString v = expr_to_string(rs->val0);
+ defer (gb_string_free(v));
+ error_line("\tSuggestion: place parentheses around the expression\n");
+ error_line("\t for (%s in %s) {\n", v, s);
+ }
+ }
}
}