Skip to content

Discover list instantiations from bare literals in wasm-gc codegen - #766

Merged
jasisz merged 1 commit into
mainfrom
wasm-gc-list-literal-discovery
Jul 30, 2026
Merged

Discover list instantiations from bare literals in wasm-gc codegen#766
jasisz merged 1 commit into
mainfrom
wasm-gc-list-literal-discovery

Conversation

@jasisz

@jasisz jasisz commented Jul 30, 2026

Copy link
Copy Markdown
Owner

The wasm-gc backend rejected any program whose only List<T> instantiation appears as a bare list literal — Console.print("{[1, 2, 3]}") in a Unit fn failed with List literal: cannot resolve list instantiation (got `List<Int>`). Surfaced by @n1bor while testing #764.

Two independent gaps in type discovery:

  • a list literal's own instantiation was never registered — discovery walked fn signatures, let annotations, and record fields, so the emitter's canonical resolution succeeded but the registry lookup missed;
  • the expression walkers never traversed string interpolations (or map literals), so nothing inside "{...}" was visible to discovery at all.

The body walk now carries Spanned nodes so the checker's type stamps are readable; list literals register their stamped type, behind a structural concreteness guard, with a first-element fallback mirroring the emitter's hint chain. All three collectors (lists, options, vectors) got the missing traversal arms, and the expression matches are now exhaustive, so a future HIR variant fails the build instead of silently skipping discovery.

Three regressions in wasm_gc_codegen_regression: interpolated bare literal, unannotated binding, nested literal — each compiled and validated with wasmparser.

wasm_gc_codegen_regression 5/5, wasm_gc_spec 37/37, cargo fmt --check clean, clippy clean with wasm features.

@jasisz
jasisz merged commit cd239c3 into main Jul 30, 2026
34 checks passed
@jasisz
jasisz deleted the wasm-gc-list-literal-discovery branch July 30, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant