WebAssembly / WebAssembly/binaryen

Invalid unreachable loop in text format

Open
#1,541 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
WebAssembly
Stars
8.6k
Forks
885
Avg merge
1d 19h
Merged PRs (30d)
69

Description

E.g.

(module
 (func $0
  (drop
   (block $label$1 (result i32)
    (loop $label$2
     (unreachable)
    )
   )
  )
 )
)

The loop is unreachable, but we need to emit an unreachable after the loop too, for the block, wabt says

w.wast:6:7: error: type mismatch in block, expected [i32] but got []

Not sure why this is just a bug in the text format - the binary for it is fine.

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.

Research direction

Start by reproducing the supplied module in the text-format parser and compare its behavior with the valid binary form. Trace handling of the unreachable loop and enclosing result-producing block; done means the text format accepts the example without the reported type-mismatch error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.