Skip to content

frontend(wasm): handle collisions of export and global names #1390

Open

Description

@mooori

Per Wasm spec the following is valid and contains counter as name of both a global and an exported function.

(module $counter_module
  (global $counter (mut i32) (i32.const 0))
  (func $read_counter (export "counter") (result i32)
    global.get $counter))

For now such a collision between global and export name is rejected with a diagnostic (#1357), as we don't expect producers to generate it.

Some notes in case we want/need to support it later on:

  • The export cannot be renamed. The export name must become the linkage name for external calls to resolve.
  • So the (private) global must be renamed and in HIR the name of the global and references to it must be rewritten.
  • The diagnostic is emitted in the wasm frontend in fn resolve_func_symbols.

Activity

  1. added
    wontfixThis will not be worked on
    frontendIssues with the compiler driver, configuration, or frontend libraries
    wasmWebAssembly-related issues or features
    irImprovements to, or bugs in, the implementation of the IR
    on Sep 11, 2026
  2. added theissue type on Sep 11, 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

    frontendIssues with the compiler driver, configuration, or frontend librariesirImprovements to, or bugs in, the implementation of the IRwasmWebAssembly-related issues or features

    Type

    Fields

    Priority

    Low

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions