$define would occasionally not properly evaluate declarations it encountered.

This commit is contained in:
Christoffer Lerno
2024-10-30 11:59:18 +01:00
parent 7f70145f55
commit 827440686f
3 changed files with 8 additions and 0 deletions

View File

@@ -1,6 +1,9 @@
// Copyright (c) 2023 Christoffer Lerno. All rights reserved. // Copyright (c) 2023 Christoffer Lerno. All rights reserved.
// Use of this source code is governed by the MIT license // Use of this source code is governed by the MIT license
// a copy of which can be found in the LICENSE_STDLIB file. // 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(<Key, Value>); module std::collections::map(<Key, Value>);
import std::math; import std::math;

View File

@@ -51,6 +51,7 @@
- Incorrect error message when `$eval` is provided an invalid string. #1570 - 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 - `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 - Named vector component access would not fold at compile time. #1574
- `$define` would occasionally not properly evaluate declarations it encountered.
### Stdlib changes ### Stdlib changes
- Remove unintended print of `char[]` as String - Remove unintended print of `char[]` as String

View File

@@ -2650,9 +2650,11 @@ static inline bool sema_expr_analyse_call(SemaContext *context, Expr *expr, bool
return sema_expr_analyse_builtin_call(context, expr); return sema_expr_analyse_builtin_call(context, expr);
case EXPR_IDENTIFIER: case EXPR_IDENTIFIER:
decl = func_expr->identifier_expr.decl; decl = func_expr->identifier_expr.decl;
if (!sema_analyse_decl(context, decl)) return false;
break; break;
case EXPR_ACCESS: case EXPR_ACCESS:
decl = func_expr->access_expr.ref; decl = func_expr->access_expr.ref;
if (!sema_analyse_decl(context, decl)) return false;
switch (decl->decl_kind) switch (decl->decl_kind)
{ {
case DECL_MACRO: 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); 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); ASSERT_SPAN(expr, member->type);
if (member->decl_kind == DECL_VAR) if (member->decl_kind == DECL_VAR)
{ {