From 1665d1efd2f5f57c6ed58945e3a56af2b3a24937 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Mon, 26 Jul 2021 11:14:40 -0700 Subject: [PATCH] don't use nested @trusted functions --- spec/function.dd | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/function.dd b/spec/function.dd index a6de616004..843f33b3a2 100644 --- a/spec/function.dd +++ b/spec/function.dd @@ -3329,6 +3329,16 @@ $(H3 $(LNAME2 trusted-functions, Trusted Functions)) that they are easier to manually verify. ) + $(BEST_PRACTICE Do not use `@trusted` nested functions in order to introduce + unsafe code into `@safe` code. Such functions tend to hide their presence + inside `@safe` code. Nested functions can manipulate variables in their + caller's scope leading to difficulty in manually verifying that it has an + `@safe` interface. + Instead, `@trusted` functions should be non-nested with a carefully designed + `@safe` interface. + `@trusted` nested functions may be deprecated in the future. + ) + $(H3 $(LNAME2 system-functions, System Functions)) $(P System functions are functions not marked with $(CODE @safe) or