bug-1744663.js (1946B)
1 gczeal(2,1); 2 3 function failureCallingTestFunction() { 4 let exports = wasmEvalText( 5 `(module 6 (tag $exn (export "exn")) 7 (func $throwExn (export "throwExn") 8 ;; Note that this does not fail if this function body is a plain (throw $exn). 9 try 10 (throw $exn) 11 end 12 ))` 13 ).exports; 14 15 let mod = 16 `(module 17 (type $exnType (func)) 18 (type $indirectFunctype (func)) 19 (import "m" "exn" (tag $exn (type $exnType))) 20 (import "m" "throwExn" (func $throwExn (type $indirectFunctype))) 21 (table funcref (elem $throwExn)) 22 (func (export "testFunc") (result i32) 23 try 24 (call_indirect (type $indirectFunctype) (i32.const 0)) 25 catch_all 26 end 27 i32.const 1))`; 28 29 let testFunction = wasmEvalText(mod, { m : exports}).exports.testFunc; 30 testFunction(); 31 }; 32 33 function failureRethrow1() { 34 let exports = wasmEvalText( 35 `(module 36 (tag $exn (export "exn")) 37 (func $throwExn (export "throwExn") 38 try 39 (throw $exn) 40 catch_all 41 try 42 throw $exn 43 catch_all 44 (rethrow 1) 45 end 46 end 47 ))` 48 ).exports; 49 50 let mod = 51 `(module 52 (type $exnType (func)) 53 (type $indirectFunctype (func)) 54 (import "m" "exn" (tag $exn (type $exnType))) 55 (import "m" "throwExn" (func $throwExn (type $indirectFunctype))) 56 (table funcref (elem $throwExn)) 57 (func (export "testFunc") (result i32) 58 try 59 (call_indirect (type $indirectFunctype) (i32.const 0)) 60 catch_all 61 end 62 (i32.const 1)))`; 63 64 let testFunction = wasmEvalText(mod, { m : exports}).exports.testFunc; 65 testFunction(); 66 }; 67 68 console.log("Calling failureCallingTestFunction."); 69 failureCallingTestFunction(); 70 console.log("Calling failureRethrow1."); 71 failureRethrow1();