Skip to content

Apparent swapped args in createWasm() #25336

@sgbeal

Description

@sgbeal

Version of emscripten/emsdk:

4.0.15 (09f5255)

From the generated module JS, stripped to the relevant parts:

async function createWasm() {
...
  /** @param {WebAssembly.Module=} module*/
  function receiveInstance(instance, module) {
    wasmExports = instance.exports;
    wasmExports = applySignatureConversions(wasmExports);
    assignWasmExports(wasmExports);
    return wasmExports;
  }
...
  if (Module['instantiateWasm']) {
    return new Promise((resolve, reject) => {
      try {
        Module['instantiateWasm'](info, (mod, inst) => {
          resolve(receiveInstance(mod, inst));
        });
      } catch(e) {
        err(`Module.instantiateWasm callback failed with error: ${e}`);
        reject(e);
      }
    });
  }
...
}

Note that Module['instantiateWasm'] is called with (mod, inst), and that's passed on as-is to receiveInstance(), but the latter is declared as taking its args in the reverse order.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions