docs(specs): make defer semantics on break/continue/return exits explicit

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.
This commit is contained in:
agra
2026-06-10 17:45:14 +03:00
parent 3cc34d54c1
commit c640e88513

View File

@@ -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