diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 52ba3148c..8bb90ecf5 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -9197,6 +9197,10 @@ static inline bool sema_expr_analyse_rethrow(SemaContext *context, Expr *expr, T context->call_env.current_function->name, type_quoted_error_string(context->rtype)); } + if (context->call_env.is_naked_fn) + { + RETURN_SEMA_ERROR(expr, "Rethrow is not allowed in a '@naked' function."); + } } return true; } diff --git a/test/test_suite/asm/naked_rethrow.c3 b/test/test_suite/asm/naked_rethrow.c3 new file mode 100644 index 000000000..72da4b570 --- /dev/null +++ b/test/test_suite/asm/naked_rethrow.c3 @@ -0,0 +1,13 @@ +import std; +fn void main() +{ + (void)test(); +} + + +fn ulong? test() @naked @noinline +{ + int? z; + z!; // #error: Rethrow is not allowed in a '@naked' function + unreachable(); +} \ No newline at end of file