github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/compiler/testdata/errors.go (about)

     1  package main
     2  
     3  import "unsafe"
     4  
     5  //go:wasmimport modulename empty
     6  func empty()
     7  
     8  // ERROR: can only use //go:wasmimport on declarations
     9  //
    10  //go:wasmimport modulename implementation
    11  func implementation() {
    12  }
    13  
    14  type Uint uint32
    15  
    16  //go:wasmimport modulename validparam
    17  func validparam(a int32, b uint64, c float64, d unsafe.Pointer, e Uint)
    18  
    19  // ERROR: //go:wasmimport modulename invalidparam: unsupported parameter type int
    20  // ERROR: //go:wasmimport modulename invalidparam: unsupported parameter type string
    21  // ERROR: //go:wasmimport modulename invalidparam: unsupported parameter type []byte
    22  // ERROR: //go:wasmimport modulename invalidparam: unsupported parameter type *int32
    23  //
    24  //go:wasmimport modulename invalidparam
    25  func invalidparam(a int, b string, c []byte, d *int32)
    26  
    27  //go:wasmimport modulename validreturn
    28  func validreturn() int32
    29  
    30  // ERROR: //go:wasmimport modulename manyreturns: too many return values
    31  //
    32  //go:wasmimport modulename manyreturns
    33  func manyreturns() (int32, int32)
    34  
    35  // ERROR: //go:wasmimport modulename invalidreturn: unsupported result type int
    36  //
    37  //go:wasmimport modulename invalidreturn
    38  func invalidreturn() int
    39  
    40  // ERROR: //go:wasmimport modulename invalidUnsafePointerReturn: unsupported result type unsafe.Pointer
    41  //
    42  //go:wasmimport modulename invalidUnsafePointerReturn
    43  func invalidUnsafePointerReturn() unsafe.Pointer