diff --git a/releasenotes.md b/releasenotes.md index bba2dc88e..08070681d 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -47,6 +47,7 @@ - Unexpected maybe-deref subscript error with out parameter #2600. - Bug on rethrow in return with defer #2603. - Fix bug when converting from vector to distinct type of wider vector. #2604 +- `$defined(hashmap.init(mem))` causes compiler segfault #2611. ### Stdlib changes - Add `CGFloat` `CGPoint` `CGSize` `CGRect` types to core_foundation (macOS). diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 0c7a9ad8d..8986e0dcd 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -3728,7 +3728,6 @@ static inline bool sema_call_analyse_member_get(SemaContext *context, Expr *expr } static inline bool sema_expr_analyse_call(SemaContext *context, Expr *expr, bool *no_match_ref) { - if (no_match_ref) *no_match_ref = true; Expr *func_expr = exprptr(expr->call_expr.function); if (!sema_analyse_expr(context, func_expr)) return false; bool optional = func_expr->type && IS_OPTIONAL(func_expr); @@ -11042,7 +11041,7 @@ static inline bool sema_expr_analyse_ct_defined(SemaContext *context, Expr *expr } case EXPR_CALL: { - bool no_match; + bool no_match = false; if (!sema_expr_analyse_call(active_context, main_expr, &no_match)) { if (!no_match) goto FAIL; diff --git a/test/unit/regression/defined_ct.c3 b/test/unit/regression/defined_ct.c3 new file mode 100644 index 000000000..1219fcb79 --- /dev/null +++ b/test/unit/regression/defined_ct.c3 @@ -0,0 +1,7 @@ +module defined_call; +import std; + +HashMap {String, int} val; +const bool V = $defined(val.init(mem)); + +fn void main() {} \ No newline at end of file