diff --git a/lib/std/collections/hashmap.c3 b/lib/std/collections/hashmap.c3 index c97a44b32..c58bd18d5 100644 --- a/lib/std/collections/hashmap.c3 +++ b/lib/std/collections/hashmap.c3 @@ -1,6 +1,9 @@ // Copyright (c) 2023 Christoffer Lerno. All rights reserved. // Use of this source code is governed by the MIT license // a copy of which can be found in the LICENSE_STDLIB file. +<* + @require $defined(Key{}.hash()) `No .hash function found on the key` +*> module std::collections::map(); import std::math; diff --git a/releasenotes.md b/releasenotes.md index 799512652..67cf246e4 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -51,6 +51,7 @@ - Incorrect error message when `$eval` is provided an invalid string. #1570 - `HashMap.copy_keys` did not properly copy keys which needed to be allocated #1569 - Named vector component access would not fold at compile time. #1574 +- `$define` would occasionally not properly evaluate declarations it encountered. ### Stdlib changes - Remove unintended print of `char[]` as String diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 311b1a186..8fae3a7c9 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -2650,9 +2650,11 @@ static inline bool sema_expr_analyse_call(SemaContext *context, Expr *expr, bool return sema_expr_analyse_builtin_call(context, expr); case EXPR_IDENTIFIER: decl = func_expr->identifier_expr.decl; + if (!sema_analyse_decl(context, decl)) return false; break; case EXPR_ACCESS: decl = func_expr->access_expr.ref; + if (!sema_analyse_decl(context, decl)) return false; switch (decl->decl_kind) { case DECL_MACRO: @@ -5003,6 +5005,8 @@ CHECK_DEEPER: RETURN_SEMA_ERROR(expr, "There is no field or method '%s.%s'.", type_to_error_string(parent->type), kw); } + if (!sema_analyse_decl(context, member)) return false; + ASSERT_SPAN(expr, member->type); if (member->decl_kind == DECL_VAR) {