Skip to content

Add target-aware type size and alignment queries #699

Closed

Description

@LunaStev

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

  1. added
    enhancement
    help wanted
    feature request
    needs testing
    cross-platform
    on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cross-platformenhancementfeature requesthelp wantedneeds testing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions