|
379 | 379 |
|
380 | 380 | (tag $e (param (ref $t)))
|
381 | 381 | (func $throw (throw $e (ref.func $dummy)))
|
382 |
| - (func (export "run") (result (ref null $t)) |
| 382 | + |
| 383 | + (func (export "catch") (result (ref null $t)) |
383 | 384 | (block $l (result (ref null $t))
|
384 | 385 | (try_table (catch $e $l) (call $throw))
|
385 | 386 | (unreachable)
|
386 | 387 | )
|
387 | 388 | )
|
| 389 | + (func (export "catch_ref1") (result (ref null $t)) |
| 390 | + (block $l (result (ref null $t) (ref exn)) |
| 391 | + (try_table (catch_ref $e $l) (call $throw)) |
| 392 | + (unreachable) |
| 393 | + ) |
| 394 | + (drop) |
| 395 | + ) |
| 396 | + (func (export "catch_ref2") (result (ref null $t)) |
| 397 | + (block $l (result (ref null $t) (ref null exn)) |
| 398 | + (try_table (catch_ref $e $l) (call $throw)) |
| 399 | + (unreachable) |
| 400 | + ) |
| 401 | + (drop) |
| 402 | + ) |
| 403 | + (func (export "catch_all_ref1") |
| 404 | + (block $l (result (ref exn)) |
| 405 | + (try_table (catch_all_ref $l) (call $throw)) |
| 406 | + (unreachable) |
| 407 | + ) |
| 408 | + (drop) |
| 409 | + ) |
| 410 | + (func (export "catch_all_ref2") |
| 411 | + (block $l (result (ref null exn)) |
| 412 | + (try_table (catch_all_ref $l) (call $throw)) |
| 413 | + (unreachable) |
| 414 | + ) |
| 415 | + (drop) |
| 416 | + ) |
388 | 417 | )
|
389 | 418 |
|
390 |
| -(assert_return (invoke "run") (ref.func)) |
| 419 | +(assert_return (invoke "catch") (ref.func)) |
| 420 | +(assert_return (invoke "catch_ref1") (ref.func)) |
| 421 | +(assert_return (invoke "catch_ref2") (ref.func)) |
| 422 | +(assert_return (invoke "catch_all_ref1")) |
| 423 | +(assert_return (invoke "catch_all_ref2")) |
| 424 | + |
| 425 | +(assert_invalid |
| 426 | + (module |
| 427 | + (type $t (func)) |
| 428 | + (tag $e (param (ref null $t))) |
| 429 | + (func (export "catch") (result (ref $t)) |
| 430 | + (block $l (result (ref $t)) |
| 431 | + (try_table (catch $e $l)) |
| 432 | + (unreachable) |
| 433 | + ) |
| 434 | + ) |
| 435 | + ) |
| 436 | + "type mismatch" |
| 437 | +) |
| 438 | +(assert_invalid |
| 439 | + (module |
| 440 | + (type $t (func)) |
| 441 | + (tag $e (param (ref null $t))) |
| 442 | + (func (export "catch_ref") (result (ref $t)) |
| 443 | + (block $l (result (ref $t) (ref exn)) |
| 444 | + (try_table (catch $e $l)) |
| 445 | + (unreachable) |
| 446 | + ) |
| 447 | + ) |
| 448 | + ) |
| 449 | + "type mismatch" |
| 450 | +) |
0 commit comments