github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/internal/integration_test/spectest/v2/testdata/br_if.wast (about)

     1  ;; Test `br_if` operator
     2  
     3  (module
     4    (func $dummy)
     5  
     6    (func (export "type-i32")
     7      (block (drop (i32.ctz (br_if 0 (i32.const 0) (i32.const 1)))))
     8    )
     9    (func (export "type-i64")
    10      (block (drop (i64.ctz (br_if 0 (i64.const 0) (i32.const 1)))))
    11    )
    12    (func (export "type-f32")
    13      (block (drop (f32.neg (br_if 0 (f32.const 0) (i32.const 1)))))
    14    )
    15    (func (export "type-f64")
    16      (block (drop (f64.neg (br_if 0 (f64.const 0) (i32.const 1)))))
    17    )
    18  
    19    (func (export "type-i32-value") (result i32)
    20      (block (result i32) (i32.ctz (br_if 0 (i32.const 1) (i32.const 1))))
    21    )
    22    (func (export "type-i64-value") (result i64)
    23      (block (result i64) (i64.ctz (br_if 0 (i64.const 2) (i32.const 1))))
    24    )
    25    (func (export "type-f32-value") (result f32)
    26      (block (result f32) (f32.neg (br_if 0 (f32.const 3) (i32.const 1))))
    27    )
    28    (func (export "type-f64-value") (result f64)
    29      (block (result f64) (f64.neg (br_if 0 (f64.const 4) (i32.const 1))))
    30    )
    31  
    32    (func (export "as-block-first") (param i32) (result i32)
    33      (block (br_if 0 (local.get 0)) (return (i32.const 2))) (i32.const 3)
    34    )
    35    (func (export "as-block-mid") (param i32) (result i32)
    36      (block (call $dummy) (br_if 0 (local.get 0)) (return (i32.const 2)))
    37      (i32.const 3)
    38    )
    39    (func (export "as-block-last") (param i32)
    40      (block (call $dummy) (call $dummy) (br_if 0 (local.get 0)))
    41    )
    42    (func (export "as-block-first-value") (param i32) (result i32)
    43      (block (result i32)
    44        (drop (br_if 0 (i32.const 10) (local.get 0))) (return (i32.const 11))
    45      )
    46    )
    47    (func (export "as-block-mid-value") (param i32) (result i32)
    48      (block (result i32)
    49        (call $dummy)
    50        (drop (br_if 0 (i32.const 20) (local.get 0)))
    51        (return (i32.const 21))
    52      )
    53    )
    54    (func (export "as-block-last-value") (param i32) (result i32)
    55      (block (result i32)
    56        (call $dummy) (call $dummy) (br_if 0 (i32.const 11) (local.get 0))
    57      )
    58    )
    59  
    60    (func (export "as-loop-first") (param i32) (result i32)
    61      (block (loop (br_if 1 (local.get 0)) (return (i32.const 2)))) (i32.const 3)
    62    )
    63    (func (export "as-loop-mid") (param i32) (result i32)
    64      (block (loop (call $dummy) (br_if 1 (local.get 0)) (return (i32.const 2))))
    65      (i32.const 4)
    66    )
    67    (func (export "as-loop-last") (param i32)
    68      (loop (call $dummy) (br_if 1 (local.get 0)))
    69    )
    70  
    71    (func (export "as-br-value") (result i32)
    72      (block (result i32) (br 0 (br_if 0 (i32.const 1) (i32.const 2))))
    73    )
    74  
    75    (func (export "as-br_if-cond")
    76      (block (br_if 0 (br_if 0 (i32.const 1) (i32.const 1))))
    77    )
    78    (func (export "as-br_if-value") (result i32)
    79      (block (result i32)
    80        (drop (br_if 0 (br_if 0 (i32.const 1) (i32.const 2)) (i32.const 3)))
    81        (i32.const 4)
    82      )
    83    )
    84    (func (export "as-br_if-value-cond") (param i32) (result i32)
    85      (block (result i32)
    86        (drop (br_if 0 (i32.const 2) (br_if 0 (i32.const 1) (local.get 0))))
    87        (i32.const 4)
    88      )
    89    )
    90  
    91    (func (export "as-br_table-index")
    92      (block (br_table 0 0 0 (br_if 0 (i32.const 1) (i32.const 2))))
    93    )
    94    (func (export "as-br_table-value") (result i32)
    95      (block (result i32)
    96        (br_table 0 0 0 (br_if 0 (i32.const 1) (i32.const 2)) (i32.const 3)) (i32.const 4)
    97      )
    98    )
    99    (func (export "as-br_table-value-index") (result i32)
   100      (block (result i32)
   101        (br_table 0 0 (i32.const 2) (br_if 0 (i32.const 1) (i32.const 3))) (i32.const 4)
   102      )
   103    )
   104    (func (export "as-return-value") (result i64)
   105      (block (result i64) (return (br_if 0 (i64.const 1) (i32.const 2))))
   106    )
   107  
   108    (func (export "as-if-cond") (param i32) (result i32)
   109      (block (result i32)
   110        (if (result i32)
   111          (br_if 0 (i32.const 1) (local.get 0))
   112          (then (i32.const 2))
   113          (else (i32.const 3))
   114        )
   115      )
   116    )
   117    (func (export "as-if-then") (param i32 i32)
   118      (block
   119        (if (local.get 0) (then (br_if 1 (local.get 1))) (else (call $dummy)))
   120      )
   121    )
   122    (func (export "as-if-else") (param i32 i32)
   123      (block
   124        (if (local.get 0) (then (call $dummy)) (else (br_if 1 (local.get 1))))
   125      )
   126    )
   127  
   128    (func (export "as-select-first") (param i32) (result i32)
   129      (block (result i32)
   130        (select (br_if 0 (i32.const 3) (i32.const 10)) (i32.const 2) (local.get 0))
   131      )
   132    )
   133    (func (export "as-select-second") (param i32) (result i32)
   134      (block (result i32)
   135        (select (i32.const 1) (br_if 0 (i32.const 3) (i32.const 10)) (local.get 0))
   136      )
   137    )
   138    (func (export "as-select-cond") (result i32)
   139      (block (result i32)
   140        (select (i32.const 1) (i32.const 2) (br_if 0 (i32.const 3) (i32.const 10)))
   141      )
   142    )
   143  
   144   (func $f (param i32 i32 i32) (result i32) (i32.const -1))
   145    (func (export "as-call-first") (result i32)
   146      (block (result i32)
   147        (call $f
   148          (br_if 0 (i32.const 12) (i32.const 1)) (i32.const 2) (i32.const 3)
   149        )
   150      )
   151    )
   152    (func (export "as-call-mid") (result i32)
   153      (block (result i32)
   154        (call $f
   155          (i32.const 1) (br_if 0 (i32.const 13) (i32.const 1)) (i32.const 3)
   156        )
   157      )
   158    )
   159    (func (export "as-call-last") (result i32)
   160      (block (result i32)
   161        (call $f
   162          (i32.const 1) (i32.const 2) (br_if 0 (i32.const 14) (i32.const 1))
   163        )
   164      )
   165    )
   166  
   167    (func $func (param i32 i32 i32) (result i32) (local.get 0))
   168    (type $check (func (param i32 i32 i32) (result i32)))
   169    (table funcref (elem $func))
   170    (func (export "as-call_indirect-func") (result i32)
   171      (block (result i32)
   172        (call_indirect (type $check)
   173          (br_if 0 (i32.const 4) (i32.const 10))
   174          (i32.const 1) (i32.const 2) (i32.const 0)
   175        )
   176      )
   177    )
   178  
   179    (func (export "as-call_indirect-first") (result i32)
   180      (block (result i32)
   181        (call_indirect (type $check)
   182          (i32.const 1) (br_if 0 (i32.const 4) (i32.const 10)) (i32.const 2) (i32.const 0)
   183        )
   184      )
   185    )
   186    (func (export "as-call_indirect-mid") (result i32)
   187      (block (result i32)
   188        (call_indirect (type $check)
   189          (i32.const 1) (i32.const 2) (br_if 0 (i32.const 4) (i32.const 10)) (i32.const 0)
   190        )
   191      )
   192    )
   193    (func (export "as-call_indirect-last") (result i32)
   194      (block (result i32)
   195        (call_indirect (type $check)
   196          (i32.const 1) (i32.const 2) (i32.const 3) (br_if 0 (i32.const 4) (i32.const 10))
   197        )
   198      )
   199    )
   200  
   201    (func (export "as-local.set-value") (param i32) (result i32)
   202      (local i32)
   203      (block (result i32)
   204        (local.set 0 (br_if 0 (i32.const 17) (local.get 0)))
   205        (i32.const -1)
   206      )
   207    )
   208    (func (export "as-local.tee-value") (param i32) (result i32)
   209      (block (result i32)
   210        (local.tee 0 (br_if 0 (i32.const 1) (local.get 0)))
   211        (return (i32.const -1))
   212      )
   213    )
   214    (global $a (mut i32) (i32.const 10))
   215    (func (export "as-global.set-value") (param i32) (result i32)
   216      (block (result i32)
   217        (global.set $a (br_if 0 (i32.const 1) (local.get 0)))
   218        (return (i32.const -1))
   219      )
   220    )
   221  
   222    (memory 1)
   223    (func (export "as-load-address") (result i32)
   224      (block (result i32) (i32.load (br_if 0 (i32.const 1) (i32.const 1))))
   225    )
   226    (func (export "as-loadN-address") (result i32)
   227      (block (result i32) (i32.load8_s (br_if 0 (i32.const 30) (i32.const 1))))
   228    )
   229  
   230    (func (export "as-store-address") (result i32)
   231      (block (result i32)
   232        (i32.store (br_if 0 (i32.const 30) (i32.const 1)) (i32.const 7)) (i32.const -1)
   233      )
   234    )
   235    (func (export "as-store-value") (result i32)
   236      (block (result i32)
   237        (i32.store (i32.const 2) (br_if 0 (i32.const 31) (i32.const 1))) (i32.const -1)
   238      )
   239    )
   240  
   241    (func (export "as-storeN-address") (result i32)
   242      (block (result i32)
   243        (i32.store8 (br_if 0 (i32.const 32) (i32.const 1)) (i32.const 7)) (i32.const -1)
   244      )
   245    )
   246    (func (export "as-storeN-value") (result i32)
   247      (block (result i32)
   248        (i32.store16 (i32.const 2) (br_if 0 (i32.const 33) (i32.const 1))) (i32.const -1)
   249      )
   250    )
   251  
   252    (func (export "as-unary-operand") (result f64)
   253      (block (result f64) (f64.neg (br_if 0 (f64.const 1.0) (i32.const 1))))
   254    )
   255    (func (export "as-binary-left") (result i32)
   256      (block (result i32) (i32.add (br_if 0 (i32.const 1) (i32.const 1)) (i32.const 10)))
   257    )
   258    (func (export "as-binary-right") (result i32)
   259      (block (result i32) (i32.sub (i32.const 10) (br_if 0 (i32.const 1) (i32.const 1))))
   260    )
   261    (func (export "as-test-operand") (result i32)
   262      (block (result i32) (i32.eqz (br_if 0 (i32.const 0) (i32.const 1))))
   263    )
   264    (func (export "as-compare-left") (result i32)
   265      (block (result i32) (i32.le_u (br_if 0 (i32.const 1) (i32.const 1)) (i32.const 10)))
   266    )
   267    (func (export "as-compare-right") (result i32)
   268      (block (result i32) (i32.ne (i32.const 10) (br_if 0 (i32.const 1) (i32.const 42))))
   269    )
   270  
   271    (func (export "as-memory.grow-size") (result i32)
   272      (block (result i32) (memory.grow (br_if 0 (i32.const 1) (i32.const 1))))
   273    )
   274  
   275    (func (export "nested-block-value") (param i32) (result i32)
   276      (i32.add
   277        (i32.const 1)
   278        (block (result i32)
   279          (drop (i32.const 2))
   280          (i32.add
   281            (i32.const 4)
   282            (block (result i32)
   283              (drop (br_if 1 (i32.const 8) (local.get 0)))
   284              (i32.const 16)
   285            )
   286          )
   287        )
   288      )
   289    )
   290  
   291    (func (export "nested-br-value") (param i32) (result i32)
   292      (i32.add
   293        (i32.const 1)
   294        (block (result i32)
   295          (drop (i32.const 2))
   296          (br 0
   297            (block (result i32)
   298              (drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 4)
   299            )
   300          )
   301          (i32.const 16)
   302        )
   303      )
   304    )
   305  
   306    (func (export "nested-br_if-value") (param i32) (result i32)
   307      (i32.add
   308        (i32.const 1)
   309        (block (result i32)
   310          (drop (i32.const 2))
   311          (drop (br_if 0
   312            (block (result i32)
   313              (drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 4)
   314            )
   315            (i32.const 1)
   316          ))
   317          (i32.const 16)
   318        )
   319      )
   320    )
   321  
   322    (func (export "nested-br_if-value-cond") (param i32) (result i32)
   323      (i32.add
   324        (i32.const 1)
   325        (block (result i32)
   326          (drop (i32.const 2))
   327          (drop (br_if 0
   328            (i32.const 4)
   329            (block (result i32)
   330              (drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 1)
   331            )
   332          ))
   333          (i32.const 16)
   334        )
   335      )
   336    )
   337  
   338    (func (export "nested-br_table-value") (param i32) (result i32)
   339      (i32.add
   340        (i32.const 1)
   341        (block (result i32)
   342          (drop (i32.const 2))
   343          (br_table 0
   344            (block (result i32)
   345              (drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 4)
   346            )
   347            (i32.const 1)
   348          )
   349          (i32.const 16)
   350        )
   351      )
   352    )
   353  
   354    (func (export "nested-br_table-value-index") (param i32) (result i32)
   355      (i32.add
   356        (i32.const 1)
   357        (block (result i32)
   358          (drop (i32.const 2))
   359          (br_table 0
   360            (i32.const 4)
   361            (block (result i32)
   362              (drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 1)
   363            )
   364          )
   365          (i32.const 16)
   366        )
   367      )
   368    )
   369  
   370  )
   371  
   372  (assert_return (invoke "type-i32"))
   373  (assert_return (invoke "type-i64"))
   374  (assert_return (invoke "type-f32"))
   375  (assert_return (invoke "type-f64"))
   376  
   377  (assert_return (invoke "type-i32-value") (i32.const 1))
   378  (assert_return (invoke "type-i64-value") (i64.const 2))
   379  (assert_return (invoke "type-f32-value") (f32.const 3))
   380  (assert_return (invoke "type-f64-value") (f64.const 4))
   381  
   382  (assert_return (invoke "as-block-first" (i32.const 0)) (i32.const 2))
   383  (assert_return (invoke "as-block-first" (i32.const 1)) (i32.const 3))
   384  (assert_return (invoke "as-block-mid" (i32.const 0)) (i32.const 2))
   385  (assert_return (invoke "as-block-mid" (i32.const 1)) (i32.const 3))
   386  (assert_return (invoke "as-block-last" (i32.const 0)))
   387  (assert_return (invoke "as-block-last" (i32.const 1)))
   388  
   389  (assert_return (invoke "as-block-first-value" (i32.const 0)) (i32.const 11))
   390  (assert_return (invoke "as-block-first-value" (i32.const 1)) (i32.const 10))
   391  (assert_return (invoke "as-block-mid-value" (i32.const 0)) (i32.const 21))
   392  (assert_return (invoke "as-block-mid-value" (i32.const 1)) (i32.const 20))
   393  (assert_return (invoke "as-block-last-value" (i32.const 0)) (i32.const 11))
   394  (assert_return (invoke "as-block-last-value" (i32.const 1)) (i32.const 11))
   395  
   396  (assert_return (invoke "as-loop-first" (i32.const 0)) (i32.const 2))
   397  (assert_return (invoke "as-loop-first" (i32.const 1)) (i32.const 3))
   398  (assert_return (invoke "as-loop-mid" (i32.const 0)) (i32.const 2))
   399  (assert_return (invoke "as-loop-mid" (i32.const 1)) (i32.const 4))
   400  (assert_return (invoke "as-loop-last" (i32.const 0)))
   401  (assert_return (invoke "as-loop-last" (i32.const 1)))
   402  
   403  (assert_return (invoke "as-br-value") (i32.const 1))
   404  
   405  (assert_return (invoke "as-br_if-cond"))
   406  (assert_return (invoke "as-br_if-value") (i32.const 1))
   407  (assert_return (invoke "as-br_if-value-cond" (i32.const 0)) (i32.const 2))
   408  (assert_return (invoke "as-br_if-value-cond" (i32.const 1)) (i32.const 1))
   409  
   410  (assert_return (invoke "as-br_table-index"))
   411  (assert_return (invoke "as-br_table-value") (i32.const 1))
   412  (assert_return (invoke "as-br_table-value-index") (i32.const 1))
   413  
   414  (assert_return (invoke "as-return-value") (i64.const 1))
   415  
   416  (assert_return (invoke "as-if-cond" (i32.const 0)) (i32.const 2))
   417  (assert_return (invoke "as-if-cond" (i32.const 1)) (i32.const 1))
   418  (assert_return (invoke "as-if-then" (i32.const 0) (i32.const 0)))
   419  (assert_return (invoke "as-if-then" (i32.const 4) (i32.const 0)))
   420  (assert_return (invoke "as-if-then" (i32.const 0) (i32.const 1)))
   421  (assert_return (invoke "as-if-then" (i32.const 4) (i32.const 1)))
   422  (assert_return (invoke "as-if-else" (i32.const 0) (i32.const 0)))
   423  (assert_return (invoke "as-if-else" (i32.const 3) (i32.const 0)))
   424  (assert_return (invoke "as-if-else" (i32.const 0) (i32.const 1)))
   425  (assert_return (invoke "as-if-else" (i32.const 3) (i32.const 1)))
   426  
   427  (assert_return (invoke "as-select-first" (i32.const 0)) (i32.const 3))
   428  (assert_return (invoke "as-select-first" (i32.const 1)) (i32.const 3))
   429  (assert_return (invoke "as-select-second" (i32.const 0)) (i32.const 3))
   430  (assert_return (invoke "as-select-second" (i32.const 1)) (i32.const 3))
   431  (assert_return (invoke "as-select-cond") (i32.const 3))
   432  
   433  (assert_return (invoke "as-call-first") (i32.const 12))
   434  (assert_return (invoke "as-call-mid") (i32.const 13))
   435  (assert_return (invoke "as-call-last") (i32.const 14))
   436  
   437  (assert_return (invoke "as-call_indirect-func") (i32.const 4))
   438  (assert_return (invoke "as-call_indirect-first") (i32.const 4))
   439  (assert_return (invoke "as-call_indirect-mid") (i32.const 4))
   440  (assert_return (invoke "as-call_indirect-last") (i32.const 4))
   441  
   442  (assert_return (invoke "as-local.set-value" (i32.const 0)) (i32.const -1))
   443  (assert_return (invoke "as-local.set-value" (i32.const 1)) (i32.const 17))
   444  
   445  (assert_return (invoke "as-local.tee-value" (i32.const 0)) (i32.const -1))
   446  (assert_return (invoke "as-local.tee-value" (i32.const 1)) (i32.const 1))
   447  
   448  (assert_return (invoke "as-global.set-value" (i32.const 0)) (i32.const -1))
   449  (assert_return (invoke "as-global.set-value" (i32.const 1)) (i32.const 1))
   450  
   451  (assert_return (invoke "as-load-address") (i32.const 1))
   452  (assert_return (invoke "as-loadN-address") (i32.const 30))
   453  
   454  (assert_return (invoke "as-store-address") (i32.const 30))
   455  (assert_return (invoke "as-store-value") (i32.const 31))
   456  (assert_return (invoke "as-storeN-address") (i32.const 32))
   457  (assert_return (invoke "as-storeN-value") (i32.const 33))
   458  
   459  (assert_return (invoke "as-unary-operand") (f64.const 1.0))
   460  (assert_return (invoke "as-binary-left") (i32.const 1))
   461  (assert_return (invoke "as-binary-right") (i32.const 1))
   462  (assert_return (invoke "as-test-operand") (i32.const 0))
   463  (assert_return (invoke "as-compare-left") (i32.const 1))
   464  (assert_return (invoke "as-compare-right") (i32.const 1))
   465  (assert_return (invoke "as-memory.grow-size") (i32.const 1))
   466  
   467  (assert_return (invoke "nested-block-value" (i32.const 0)) (i32.const 21))
   468  (assert_return (invoke "nested-block-value" (i32.const 1)) (i32.const 9))
   469  (assert_return (invoke "nested-br-value" (i32.const 0)) (i32.const 5))
   470  (assert_return (invoke "nested-br-value" (i32.const 1)) (i32.const 9))
   471  (assert_return (invoke "nested-br_if-value" (i32.const 0)) (i32.const 5))
   472  (assert_return (invoke "nested-br_if-value" (i32.const 1)) (i32.const 9))
   473  (assert_return (invoke "nested-br_if-value-cond" (i32.const 0)) (i32.const 5))
   474  (assert_return (invoke "nested-br_if-value-cond" (i32.const 1)) (i32.const 9))
   475  (assert_return (invoke "nested-br_table-value" (i32.const 0)) (i32.const 5))
   476  (assert_return (invoke "nested-br_table-value" (i32.const 1)) (i32.const 9))
   477  (assert_return (invoke "nested-br_table-value-index" (i32.const 0)) (i32.const 5))
   478  (assert_return (invoke "nested-br_table-value-index" (i32.const 1)) (i32.const 9))
   479  
   480  (assert_invalid
   481    (module (func $type-false-i32 (block (i32.ctz (br_if 0 (i32.const 0))))))
   482    "type mismatch"
   483  )
   484  (assert_invalid
   485    (module (func $type-false-i64 (block (i64.ctz (br_if 0 (i32.const 0))))))
   486    "type mismatch"
   487  )
   488  (assert_invalid
   489    (module (func $type-false-f32 (block (f32.neg (br_if 0 (i32.const 0))))))
   490    "type mismatch"
   491  )
   492  (assert_invalid
   493    (module (func $type-false-f64 (block (f64.neg (br_if 0 (i32.const 0))))))
   494    "type mismatch"
   495  )
   496  
   497  (assert_invalid
   498    (module (func $type-true-i32 (block (i32.ctz (br_if 0 (i32.const 1))))))
   499    "type mismatch"
   500  )
   501  (assert_invalid
   502    (module (func $type-true-i64 (block (i64.ctz (br_if 0 (i64.const 1))))))
   503    "type mismatch"
   504  )
   505  (assert_invalid
   506    (module (func $type-true-f32 (block (f32.neg (br_if 0 (f32.const 1))))))
   507    "type mismatch"
   508  )
   509  (assert_invalid
   510    (module (func $type-true-f64 (block (f64.neg (br_if 0 (i64.const 1))))))
   511    "type mismatch"
   512  )
   513  
   514  (assert_invalid
   515    (module (func $type-false-arg-void-vs-num (result i32)
   516      (block (result i32) (br_if 0 (i32.const 0)) (i32.const 1))
   517    ))
   518    "type mismatch"
   519  )
   520  (assert_invalid
   521    (module (func $type-true-arg-void-vs-num (result i32)
   522      (block (result i32) (br_if 0 (i32.const 1)) (i32.const 1))
   523    ))
   524    "type mismatch"
   525  )
   526  (assert_invalid
   527    (module (func $type-false-arg-num-vs-void
   528      (block (br_if 0 (i32.const 0) (i32.const 0)))
   529    ))
   530    "type mismatch"
   531  )
   532  (assert_invalid
   533    (module (func $type-true-arg-num-vs-void
   534      (block (br_if 0 (i32.const 0) (i32.const 1)))
   535    ))
   536    "type mismatch"
   537  )
   538  
   539  (assert_invalid
   540    (module (func $type-false-arg-void-vs-num (result i32)
   541      (block (result i32) (br_if 0 (nop) (i32.const 0)) (i32.const 1))
   542    ))
   543    "type mismatch"
   544  )
   545  (assert_invalid
   546    (module (func $type-true-arg-void-vs-num (result i32)
   547      (block (result i32) (br_if 0 (nop) (i32.const 1)) (i32.const 1))
   548    ))
   549    "type mismatch"
   550  )
   551  (assert_invalid
   552    (module (func $type-false-arg-num-vs-num (result i32)
   553      (block (result i32)
   554        (drop (br_if 0 (i64.const 1) (i32.const 0))) (i32.const 1)
   555      )
   556    ))
   557    "type mismatch"
   558  )
   559  (assert_invalid
   560    (module (func $type-true-arg-num-vs-num (result i32)
   561      (block (result i32)
   562        (drop (br_if 0 (i64.const 1) (i32.const 0))) (i32.const 1)
   563      )
   564    ))
   565    "type mismatch"
   566  )
   567  
   568  (assert_invalid
   569    (module (func $type-cond-empty-vs-i32
   570      (block (br_if 0))
   571    ))
   572    "type mismatch"
   573  )
   574  (assert_invalid
   575    (module (func $type-cond-void-vs-i32
   576      (block (br_if 0 (nop)))
   577    ))
   578    "type mismatch"
   579  )
   580  (assert_invalid
   581    (module (func $type-cond-num-vs-i32
   582      (block (br_if 0 (i64.const 0)))
   583    ))
   584    "type mismatch"
   585  )
   586  (assert_invalid
   587    (module (func $type-arg-cond-void-vs-i32 (result i32)
   588      (block (result i32) (br_if 0 (i32.const 0) (nop)) (i32.const 1))
   589    ))
   590    "type mismatch"
   591  )
   592  (assert_invalid
   593    (module (func $type-arg-void-vs-num-nested (result i32)
   594      (block (result i32) (i32.const 0) (block (br_if 1 (i32.const 1))))
   595    ))
   596    "type mismatch"
   597  )
   598  (assert_invalid
   599    (module (func $type-arg-cond-num-vs-i32 (result i32)
   600      (block (result i32) (br_if 0 (i32.const 0) (i64.const 0)) (i32.const 1))
   601    ))
   602    "type mismatch"
   603  )
   604  
   605  (assert_invalid
   606    (module
   607      (func $type-1st-cond-empty-in-then
   608        (block
   609          (i32.const 0) (i32.const 0)
   610          (if (result i32) (then (br_if 0)))
   611        )
   612        (i32.eqz) (drop)
   613      )
   614    )
   615    "type mismatch"
   616  )
   617  (assert_invalid
   618    (module
   619      (func $type-2nd-cond-empty-in-then
   620        (block
   621          (i32.const 0) (i32.const 0)
   622          (if (result i32) (then (br_if 0 (i32.const 1))))
   623        )
   624        (i32.eqz) (drop)
   625      )
   626    )
   627    "type mismatch"
   628  )
   629  (assert_invalid
   630    (module
   631      (func $type-1st-cond-empty-in-return
   632        (block (result i32)
   633          (return (br_if 0))
   634        )
   635        (i32.eqz) (drop)
   636      )
   637    )
   638    "type mismatch"
   639  )
   640  (assert_invalid
   641    (module
   642      (func $type-2nd-cond-empty-in-return
   643        (block (result i32)
   644          (return (br_if 0 (i32.const 1)))
   645        )
   646        (i32.eqz) (drop)
   647      )
   648    )
   649    "type mismatch"
   650  )
   651  
   652  
   653  (assert_invalid
   654    (module (func $unbound-label (br_if 1 (i32.const 1))))
   655    "unknown label"
   656  )
   657  (assert_invalid
   658    (module (func $unbound-nested-label (block (block (br_if 5 (i32.const 1))))))
   659    "unknown label"
   660  )
   661  (assert_invalid
   662    (module (func $large-label (br_if 0x10000001 (i32.const 1))))
   663    "unknown label"
   664  )
   665