Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Clarification: Why do try blocks need a result type? #83

Closed
@mirkosertic

Description

@mirkosertic

Given the following textual representation:

(module
  (func (export "dosomething") (result i32)
    (try $globalTry
      (return (i32.const 10))
      (catch
        (rethrow)
      )
     )
  )
)

yields the following validation error:

Error: validate failed:
test.wast:5:7: error: type mismatch in implicit return, expected [i32] but got []
      (catch
      ^

The following code with an additional result type on the try block passes validation:

(module
  (func (export "dosomething") (result i32)
    (try $globalTry (result i32)
      (return (i32.const 10))
      (catch
        (rethrow)
      )
     )
  )
)

I really don't get why the result type on try is needed, as the block either returns directly of rethrows an exception. I'd like to request a clarification on this.

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