Repository navigation
Description
Problem
Wave's typed allocation helpers currently require callers to supply elem_size manually. std/mem/alloc.wave:103 explicitly notes that the language does not expose a type-size query. Generic containers cannot reliably derive the size or alignment of their element type, including padding and differences between compilation targets.
Scope
Provide compile-time queries for the storage size and alignment of a concrete Wave type, using the selected compilation target rather than the compiler host. The proposed call form is size_of<T>() and align_of<T>(); implementation should define the result type and supported type categories before landing.
This concerns object storage layout, not C ABI argument transport. Keep it independent of new allocation ownership rules and external libraries. Do not introduce a language grammar document as part of this issue.
Completion criteria
- Resolve scalar, pointer, array, struct, enum, and payload-variant types after generic specialization.
- Use target-correct storage size and alignment, including aggregate padding and wasm32/wasm64 pointer differences.
- Reject unresolved or unsupported type queries with source diagnostics rather than backend panics.
- Queries do not evaluate a runtime operand or allocate memory.
- Add target-layout regression tests and executable generic-allocation examples.
- Preserve existing raw allocation helpers; any safer convenience API must use the actual storage layout.
Difficulty: medium to high. This is not a good first issue. Related #350 covers broader ABI work; #450 concerns variant layout optimization.
Activity
Fix typed codegen and expand portable std capabilities (#701)