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:
6
specs.md
6
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
|
||||
|
||||
Reference in New Issue
Block a user