From c640e885137a141a3b28de7a62662820db572137 Mon Sep 17 00:00:00 2001 From: agra Date: Wed, 10 Jun 2026 17:45:14 +0300 Subject: [PATCH] docs(specs): make defer semantics on break/continue/return exits explicit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Defer section only said 'when the enclosing scope block exits', which left the break/continue paths implicit — the exact ambiguity issue 0108 hid behind. State all three exit kinds and the break/continue-outside-loop diagnostic. --- specs.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/specs.md b/specs.md index 3c3ded9..2f6396c 100644 --- a/specs.md +++ b/specs.md @@ -2257,6 +2257,12 @@ A variable declaration (`name :=`) inside an inner scope shadows any variable wi // prints: first, then second ``` +`break` and `continue` exit the loop body's scope: the iteration's pending +defers run (LIFO, including entries from nested blocks between the loop and +the jump) before control transfers — exactly as on the fall-through end of an +iteration. `return` runs all pending defers of the function. A `break` or +`continue` outside a loop is a compile-time error. + --- ## 7. Built-in Functions