Skip to content

Second Webassembly fn import of the same name but different module name is ignored #12880

@Pyrolistical

Description

@Pyrolistical

Zig Version

0.10.0-dev.4060+61aaef0b0

Steps to Reproduce

  1. Create two files that both import a function of the same name, but with different module names
  2. Import two files into a 3rd one and call both functions.
  3. Make webassembly build
  4. Decompile webassembly
  5. Observe the declared import functions

a.zig

pub extern "a" fn hello() i32;

b.zig

pub extern "b" fn hello() i32;

double-hello.zig

const a = @import("a.zig");
const b = @import("b.zig");

extern "env" fn out(value: i32) void;
export fn doubleHello() void {
    out(a.hello());
    out(b.hello());
}

build command zig build-lib double-hello.zig -target wasm32-freestanding -dynamic

decompile double-hello.wasm using https://webassembly.github.io/wabt/demo/wasm2wat/

Expected Behavior

In decompiled wasm, expected two hello functions.

  (import "a" "hello" (func $a_hello ...
  (import "b" "hello" (func $b_hello ...

Actual Behavior

In decompiled wasm, only found a.hello

  (import "a" "hello" (func $hello ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-wasm32-bit and 64-bit WebAssemblybugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions