github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/internal/integration_test/spectest/v1/testdata/func.wast (about)

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