From 0ee38df743fdcff80fa933ce32ab3da6203e44a5 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Wed, 21 Feb 2024 21:54:07 +0100 Subject: [PATCH] :art: improve pre_ctor diagnostics --- src/parse/scan1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 83cdb98b..0d9b565a 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -588,7 +588,7 @@ ANN bool scan1_union_def(const Env env, const Union_Def udef) { #define scan1_stmt_retry dummy_func ANN static bool scan1_stmt_return(const Env env, const Stmt_Exp stmt) { - if (!env->func) + if (!env->func || is_ctor(env->func->def)) ERR_B(stmt_self(stmt)->loc, _("'return' statement found outside function definition")); if (env->scope->depth == 1) env->func->memoize = 1; -- 2.43.0