cli: restrict source scope names to lexical task operands

This commit is contained in:
dev committed 2026-10-07 19:50:49 +03:00
1 parent 364eb57bbc
commit 9001e56325
32 files changed
+307 -6

No files matched your search

+5 -1
View File
@@ -257,7 +257,11 @@ scope s {
}
```
**`scope s { … }`** is `task.scope.begin` and `task.scope.end`, at every normal exit of the block. Inside it:
**`scope s { … }`** is `task.scope.begin` and `task.scope.end`, at every normal exit of the block.
The name `s` MUST denote only a lexical scope identifier, used by name as the first operand of `task.spawn`. It MUST NOT be used as an ordinary value (`s` or `move s`: `E7006`, reason `invalid_expression`) or borrowed (`E7006`, reason `invalid_place`). Assignment to this immutable identifier is `E7006`, reason `invalid_assignment`. Consequently it cannot be aliased, yielded, returned, put in an aggregate or passed as an ordinary argument. Ordinary lexical shadowing remains permitted: lookup selects the innermost binding, while completion always consumes the originating block's saved AIR scope identity. Leaving a shadowing block restores the outer binding; an unjoined child still rejects with `E4301`. This source restriction does not change function-local AIR scope flow (spec 04 §33).
Task operations inside the block:
- `task.spawn(s, f, args)` spawns `f` (a local or directly imported qualified function, §14) into the scope `s`. Arguments are passed like call arguments: a named linear value is `move`d (`E7003`). A borrow argument is lent until the join (spec 04 §34), so it is a borrow binding passed by name (`mut part = buf;` … `task.spawn(s, f, part)`). A borrow or byte string written inline is `E7006`, because a temporary would have to end right after the spawn. The first operand must be the scope (`E7005`);
- `task.join(move t)` joins; its value is the task's result (`task<T>` gives `T`);