Skip to content

fix(elem declare): do not instantiate a declarative element#6557

Merged
marxin merged 1 commit intomainfrom
declared-element-segment
May 6, 2026
Merged

fix(elem declare): do not instantiate a declarative element#6557
marxin merged 1 commit intomainfrom
declared-element-segment

Conversation

@marxin
Copy link
Copy Markdown
Contributor

@marxin marxin commented May 5, 2026

Fixes: #6534

Copilot AI review requested due to automatic review settings May 5, 2026 11:37
@marxin marxin requested a review from syrusakbary as a code owner May 5, 2026 11:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the compiler translation path so that declarative element segments are not instantiated/parsed into runtime element data, which prevents valid modules (e.g. using global.get in a declarative element initializer) from being rejected during compile/run.

Changes:

  • Skip reading/parsing element items for ElementKind::Declared to avoid triggering unsupported-init-expr errors for declarative segments.
  • Add a regression test covering a declarative element segment whose initializer is (global.get 0) (issue #6534).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/compiler/src/translator/sections.rs Moves read_elems(&items) into the Active/Passive arms so Declarative segments are ignored (not instantiated).
tests/compilers/issues.rs Adds a compiler regression test that compiles/instantiates a module containing a declarative element segment initialized via global.get.

@marxin marxin merged commit 2f20d17 into main May 6, 2026
76 checks passed
@marxin marxin deleted the declared-element-segment branch May 6, 2026 07:21
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.

Wasmer compile rejects valid global.get element segment init expression

3 participants