Skip to content

wasm2c: reject contradictory imports instead of aborting - #2813

Open
ANAMASGARD wants to merge 1 commit into
WebAssembly:mainfrom
ANAMASGARD:fix/wasm2c-contradictory-import-abort
Open

wasm2c: reject contradictory imports instead of aborting#2813
ANAMASGARD wants to merge 1 commit into
WebAssembly:mainfrom
ANAMASGARD:fix/wasm2c-contradictory-import-abort

Conversation

@ANAMASGARD

@ANAMASGARD ANAMASGARD commented Aug 8, 2026

Copy link
Copy Markdown

Fixes #2751

Summary

  • Replace UNIMPLEMENTED("contradictory import declaration") with a stderr diagnostic and Result::Error
  • Preflight ComputeUniqueImports() at the start of WriteModule() so codegen never runs on unlinkable modules
  • Add test/wasm2c/contradictory-imports.txt

Test plan

  • Manual: wasm2c dup.wasm exits 1 with error message (no abort)
  • python3 test/run-tests.py test/wasm2c/contradictory-imports.txt
  • python3 test/run-tests.py test/wasm2c/
  • ./out/wabt-unittests
image

Preflight ComputeUniqueImports() before codegen and return Result::Error
when the same module/field name is imported with different external kinds,
instead of hitting UNIMPLEMENTED/abort on valid-but-unlinkable modules.
Fixes WebAssembly#2751

Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
@shravanrn
shravanrn requested review from keithw and sbc100 August 8, 2026 18:28
@sbc100

sbc100 commented Aug 8, 2026

Copy link
Copy Markdown
Member

Seems reasonable to me

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.

wasm2c: abort (UNIMPLEMENTED contradictory import declaration) on a valid module with same-named imports of different kinds

2 participants