diff --git a/releasenotes.md b/releasenotes.md index 124c21281..bff06e365 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -14,6 +14,7 @@ - Incorrect subscript resolution #1519. - Segfault with passing a program with `-` using stdin. - Using no module with `-` would reject the program. +- Unintended deref of pointers with methods caused regression with hash function. ### Stdlib changes - Remove unintended print of `char[]` as String diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 9217b5118..1cace7d64 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -2618,16 +2618,18 @@ static inline bool sema_expr_analyse_call(SemaContext *context, Expr *expr, bool case DECL_MACRO: struct_var = func_expr->access_expr.parent; if (decl->func_decl.signature.params[0]->var.kind == VARDECL_PARAM_REF) break; - if (decl->func_decl.signature.params[0]->type->type_kind == TYPE_POINTER) + if (decl->func_decl.signature.params[0]->type->canonical != struct_var->type->canonical + && decl->func_decl.signature.params[0]->type->type_kind == TYPE_POINTER) { expr_insert_addr(struct_var); } break; case DECL_FUNC: struct_var = func_expr->access_expr.parent; - if (decl->func_decl.signature.params[0]->type->type_kind == TYPE_POINTER) + if (decl->func_decl.signature.params[0]->type->type_kind == TYPE_POINTER ) { - if (!decl->func_decl.attr_interface_method) + if (decl->func_decl.signature.params[0]->type->canonical != struct_var->type->canonical + && !decl->func_decl.attr_interface_method) { expr_insert_addr(struct_var); }