;;; TOOL: run-roundtrip
;;; ARGS: --stdout --fold-exprs --generate-names

;; This was folding incorrectly since the import index was being used as the
;; function index, so the folder didn't know how many parameters the function
;; had.

(module
  (import "a" "b" (global i32))
  (import "c" "d" (func $g (param i32 i32) (result i32)))
  (func $f (param i32))
  (func
    (call $f
      (call $g
        (i32.const 1)
        (i32.const 2)))))

(;; STDOUT ;;;
(module
  (type $t0 (func (param i32 i32) (result i32)))
  (type $t1 (func (param i32)))
  (type $t2 (func))
  (import "a" "b" (global $a.b i32))
  (import "c" "d" (func $c.d (type $t0)))
  (func $f1 (type $t1) (param $p0 i32))
  (func $f2 (type $t2)
    (call $f1
      (call $c.d
        (i32.const 1)
        (i32.const 2)))))
;;; STDOUT ;;)
