;;; TOOL: wat2wasm
;;; ARGS: --enable-reference-types

(module
  (table $foo 1 anyref)
  (table $bar 1 anyref)
  (table $baz 1 anyfunc)
  (table $qux 1 nullref)

  (func (result anyref)
    i32.const 0
    table.get $foo
  )
  (func (result anyref)
    i32.const 0
    table.get $bar
  )
  (func (result nullref)
    i32.const 0
    table.get $qux
  )

  (func (param anyref)
    i32.const 0
    get_local 0
    table.set $foo
  )
  (func (param anyref)
    i32.const 0
    get_local 0
    table.set $bar
  )
  (func (param nullref)
    i32.const 0
    get_local 0
    table.set $qux
  )

  (func (result i32)
    ref.null
    i32.const 0
    table.grow $foo
  )
  (func (result i32)
    ref.null
    i32.const 0
    table.grow $bar
  )

  (func (param anyref) (result i32)
    local.get 0
    ref.is_null
  )

  (func (result anyref)
    ref.func 0
  )
  (func (result nullref)
    ref.null
  )

  (func (result i32)
    table.size $foo
  )
  (func (result i32)
    table.size $bar
  )
  (func (result i32)
    table.size $baz
  )
)
