feat: contextually type empty mutable slice literals

This commit is contained in:
2026-10-25 01:09:27 +02:00
parent 3a90a90428
commit ecb7b2fc64
3 changed files with 142 additions and 10 deletions
+11
View File
@@ -50,6 +50,17 @@ roadmap and milestone history.
- fallible channel types `T ! E`, where `E` is a native enum, native struct, tagged union, or supported sum composition; `void ! E` functions complete successfully on fallthrough, and void-success `catch` handlers may fall through without `yield`
- bodyful local functions and root `main` may write `T!` to infer a specialization-local error channel from propagated `try` expressions and concretely typed error returns; inference composes only existing named error types, never synthesizes variants, and requires at least one inferred error
#### contextual empty mutable slices
A fresh empty array literal address `&[]` may initialize an expected `[]mut T`,
including local declarations, call arguments, and record fields. The context supplies
the element type `T`; the resulting slice has length zero and no writable elements.
This is literal-only contextual typing, not a readonly-to-mutable conversion:
named readonly zero-length arrays, existing readonly empty slices, and nonempty
readonly literals still cannot initialize mutable slices. Sentinel slices `[;S]T`
and `[;S]mut T` still require backing storage containing the sentinel; `&[]` does
not provide it.
#### checked sentinel slicing
`base[start..end;S]` constructs a sentinel slice `[;S]T` without copying elements.