@ 261106.8
current
;; NOTE: Assertions have been generated by update_lit_checks.py --output=fuzz-exec and should not be edited.

;; RUN: foreach %s %t wasm-opt -all --fuzz-exec-before | filecheck %s

;; The start function tries to call an export. This reentrancy of course does
;; not work in JS (the module is not ready - no exports have been provided) so
;; it throws when trying to call undefined (what we get from the un-populated
;; list of exports). We should have the same behavior: rather than call $trap
;; and trap, we should throw a JS exception which call-export-catch *catches*.
;; The module initializes without error, and we then call the two exports in
;; order.
(module
  (import "fuzzing-support" "call-export-catch" (func $call-export-catch (param i32) (result i32)))

  (global $g (mut i32) (i32.const 0))

  (start $start)

  (func $start
    (drop
      (call $call-export-catch
        (i32.const 1)
      )
    )
    ;; This set executes, affecting the result of $ok, below.
    (global.set $g
      (i32.const 1)
    )
  )

  ;; CHECK:      [fuzz-exec] export ok
  ;; CHECK-NEXT: [fuzz-exec] note result: ok => 1
  (func $ok (export "ok") (result i32)
    (global.get $g)
  )

  ;; CHECK:      [fuzz-exec] export trap
  ;; CHECK-NEXT: [trap unreachable]
  (func $trap (export "trap")
    (unreachable)
  )
)