Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

BinaryenAddFunctionImport lost internalName on export, is this intentional?

Open
#7,272 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, wasm
Domain
api, compilers

Research direction

Start at the implementation of BinaryenAddFunctionImport shown in the issue and compare it with BinaryenAddFunction, then inspect how BinaryenGetFunction and export naming use internalName. Verify the current behavior for imported functions and determine what API behavior or naming preservation should be covered before adding a focused regression test.

Written by the indexing model from the issue text.

Description

 BinaryenAddFunctionImport(module, internalName, "env", "externalBaseName", params, result);
BinaryenFunctionRef func = BinaryenGetFunction(module, ret);
func->setExplicitName(internalName);

i think add and Get , It's a bit wasteful. why not return BinaryenFunctionRef on BinaryenAddFunctionImport?
i find that, BinaryenAddFunction directly setExplicitName. why not BinaryenAddFunctionImport?

void BinaryenAddFunctionImport(BinaryenModuleRef module,
                               const char* internalName,
                               const char* externalModuleName,
                               const char* externalBaseName,
                               BinaryenType params,
                               BinaryenType results) {
  auto* func = ((Module*)module)->getFunctionOrNull(internalName);
  if (func == nullptr) {
    auto func = std::make_unique<Function>();
    if (internalName)
      func->setExplicitName(internalName); 
    func->name = internalName;
    func->module = externalModuleName;
    func->base = externalBaseName;
    // TODO: Take a HeapType rather than params and results.
    func->type = Signature(Type(params), Type(results));
    ((Module*)module)->addFunction(std::move(func));
  } else {
    // already exists so just set module and base
    func->module = externalModuleName;
    func->base = externalBaseName;
  }
}
Dominant language
WebAssembly
Stars
8.6k
Forks
885
Avg merge
2d 4h
Merged PRs (30d)
77

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WebAssembly/binaryen

All issues in WebAssembly/binaryen

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.