(module
  (type $t (func))
  (func (export "anyref") (result anyref) (ref.null any))
  (func (export "funcref") (result funcref) (ref.null func))
  (func (export "ref") (result (ref null $t)) (ref.null $t))

  (global anyref (ref.null any))
  (global funcref (ref.null func))
  (global (ref null $t) (ref.null $t))
)

(assert_return (invoke "anyref") (ref.null any))
(assert_return (invoke "funcref") (ref.null func))
(assert_return (invoke "ref") (ref.null))


(module
  (type $t (func))
  (global $null nullref (ref.null none))
  (global $nullfunc nullfuncref (ref.null nofunc))
  (global $nullextern nullexternref (ref.null noextern))
  (func (export "anyref") (result anyref) (global.get $null))
  (func (export "nullref") (result nullref) (global.get $null))
  (func (export "funcref") (result funcref) (global.get $nullfunc))
  (func (export "nullfuncref") (result nullfuncref) (global.get $nullfunc))
  (func (export "externref") (result externref) (global.get $nullextern))
  (func (export "nullexternref") (result nullexternref) (global.get $nullextern))
  (func (export "ref") (result (ref null $t)) (global.get $nullfunc))

  (global anyref (ref.null any))
  (global anyref (ref.null none))
  (global funcref (ref.null func))
  (global funcref (ref.null nofunc))
  (global externref (ref.null extern))
  (global externref (ref.null noextern))
  (global nullref (ref.null none))
  (global nullfuncref (ref.null nofunc))
  (global nullexternref (ref.null noextern))
  (global (ref null $t) (ref.null $t))
  (global (ref null $t) (ref.null nofunc))
)

(assert_return (invoke "anyref") (ref.null any))
(assert_return (invoke "anyref") (ref.null none))
(assert_return (invoke "anyref") (ref.null))
(assert_return (invoke "nullref") (ref.null any))
(assert_return (invoke "nullref") (ref.null none))
(assert_return (invoke "nullref") (ref.null))
(assert_return (invoke "funcref") (ref.null func))
(assert_return (invoke "funcref") (ref.null nofunc))
(assert_return (invoke "funcref") (ref.null))
(assert_return (invoke "nullfuncref") (ref.null func))
(assert_return (invoke "nullfuncref") (ref.null nofunc))
(assert_return (invoke "nullfuncref") (ref.null))
(assert_return (invoke "externref") (ref.null extern))
(assert_return (invoke "externref") (ref.null noextern))
(assert_return (invoke "externref") (ref.null))
(assert_return (invoke "nullexternref") (ref.null extern))
(assert_return (invoke "nullexternref") (ref.null noextern))
(assert_return (invoke "nullexternref") (ref.null))
(assert_return (invoke "ref") (ref.null func))
(assert_return (invoke "ref") (ref.null nofunc))
(assert_return (invoke "ref") (ref.null))
