scalar family constraints for struct fields

This commit is contained in:
2026-07-13 23:00:42 +02:00
parent 6de4d9f9f3
commit 0eeacc2e37
3 changed files with 585 additions and 12 deletions
+14
View File
@@ -39,6 +39,20 @@ roadmap and milestone history.
- native sum composition with `A | B` for unbacked enums and tagged unions, using program-global `u16` variant ids
- fallible channel types `T ! E`, where `E` is a native enum/tagged union or supported sum composition
#### native record constraint fields
A direct `int`, `float`, or `range` field in a named native struct or union is a
program-wide constraint, not per-value polymorphism. Before record layout, all reachable keyed
constructors, field assignments, and concrete uses of field reads contribute demands and the field
resolves once to one concrete runtime type. Compatible scalar demands widen normally. Integer
literals remain provisional until inference settles, so a later `usize` use can resolve an `int`
field to `usize`; otherwise literal-only `int` fields use the widest smallest-signed type required,
and literal-only `float` fields use `f64`.
An undemanded field or incompatible demands are errors. This inference applies only to direct
fields of named native records. `c_struct` fields, nested constraints such as `[]int`, and fields in
anonymous generated records still require concrete runtime types.
#### keyword member names
Reserved keywords are valid native enum members and tagged-union variants when used in an