Skip to content

Add a focused generics example #658

Closed

Description

@LunaStev

Why

Generic structs, generic functions, nested type arguments, and generic method specialization are covered by parser/compiler tests, but there is no small maintained example dedicated to teaching the feature.

The existing WebAssembly smoke example uses generics as one feature among many, which makes it a poor reference for someone learning the syntax.

Scope

Add a focused runnable example under examples/ that demonstrates the currently supported generic syntax without introducing unrelated platform or standard-library behavior.

Include:

  • a generic Box<T>-style struct;
  • a Pair<A, B>-style struct with two type parameters;
  • a generic function called with an explicit type argument;
  • construction and field access for generic structs;
  • at least one nested generic type such as Pair<i32, Box<i64>>.

Keep the example aligned with the syntax and semantics already covered by the frontend generic tests.

Completion criteria

  • The example passes wavec check and runs successfully on a normal hosted target.
  • It demonstrates more than one concrete generic instantiation.
  • Nested generic type arguments are included without turning the file into a stress test.
  • No unsupported generic feature is documented implicitly.
  • The example is listed in the examples index or local README.

Activity

  1. added
    documentation
    good first issue
    needs testing
    on Sep 15, 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

    documentationgood first issueneeds testing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions