;;; TOOL: wat2wasm
;;; ERROR: 1
;;; ARGS: --enable-all

(;
Note that this test covers an interaction between the memory64 and
multi-memory proposals.

Neither proposal includes a test like this because each proposal only
implements itself on top of the current standard. Once one of the two proposals
is standardized, this test should be removed in favor of a spec test in the
proposal that is yet to be standardized.
;)

(module
  (memory $mem64 i64 1)
  (memory $mem32 i32 1)
  (func
    (; i64 -> i32 ;)
    i64.const 0
    i64.const 0
    i32.const 0
    memory.copy $mem32 $mem64

    i32.const 0
    i32.const 0
    i32.const 0
    memory.copy $mem32 $mem64

    i32.const 0
    i64.const 0
    i64.const 0
    memory.copy $mem32 $mem64

    (; i32 -> i64 ;)
    i32.const 0
    i32.const 0
    i32.const 0
    memory.copy $mem64 $mem32

    i64.const 0
    i64.const 0
    i32.const 0
    memory.copy $mem64 $mem32

    i64.const 0
    i32.const 0
    i64.const 0
    memory.copy $mem64 $mem32

    (; i64 -> i64 ;)
    i32.const 0
    i64.const 0
    i64.const 0
    memory.copy $mem64 $mem64

    i64.const 0
    i32.const 0
    i64.const 0
    memory.copy $mem64 $mem64

    i64.const 0
    i64.const 0
    i32.const 0
    memory.copy $mem64 $mem64

    (; i32 -> i32 ;)
    i64.const 0
    i32.const 0
    i32.const 0
    memory.copy $mem32 $mem32

    i32.const 0
    i64.const 0
    i32.const 0
    memory.copy $mem32 $mem32

    i32.const 0
    i32.const 0
    i64.const 0
    memory.copy $mem32 $mem32
  )
)

(;; STDERR ;;;
out/test/parse/expr/bad-memory-copy-differing-type.txt:23:5: error: type mismatch in memory.copy, expected [i32, i64, i32] but got [i64, i64, i32]
    memory.copy $mem32 $mem64
    ^^^^^^^^^^^
out/test/parse/expr/bad-memory-copy-differing-type.txt:28:5: error: type mismatch in memory.copy, expected [i32, i64, i32] but got [i32, i32, i32]
    memory.copy $mem32 $mem64
    ^^^^^^^^^^^
out/test/parse/expr/bad-memory-copy-differing-type.txt:33:5: error: type mismatch in memory.copy, expected [i32, i64, i32] but got [i32, i64, i64]
    memory.copy $mem32 $mem64
    ^^^^^^^^^^^
out/test/parse/expr/bad-memory-copy-differing-type.txt:39:5: error: type mismatch in memory.copy, expected [i64, i32, i32] but got [i32, i32, i32]
    memory.copy $mem64 $mem32
    ^^^^^^^^^^^
out/test/parse/expr/bad-memory-copy-differing-type.txt:44:5: error: type mismatch in memory.copy, expected [i64, i32, i32] but got [i64, i64, i32]
    memory.copy $mem64 $mem32
    ^^^^^^^^^^^
out/test/parse/expr/bad-memory-copy-differing-type.txt:49:5: error: type mismatch in memory.copy, expected [i64, i32, i32] but got [i64, i32, i64]
    memory.copy $mem64 $mem32
    ^^^^^^^^^^^
out/test/parse/expr/bad-memory-copy-differing-type.txt:55:5: error: type mismatch in memory.copy, expected [i64, i64, i64] but got [i32, i64, i64]
    memory.copy $mem64 $mem64
    ^^^^^^^^^^^
out/test/parse/expr/bad-memory-copy-differing-type.txt:60:5: error: type mismatch in memory.copy, expected [i64, i64, i64] but got [i64, i32, i64]
    memory.copy $mem64 $mem64
    ^^^^^^^^^^^
out/test/parse/expr/bad-memory-copy-differing-type.txt:65:5: error: type mismatch in memory.copy, expected [i64, i64, i64] but got [i64, i64, i32]
    memory.copy $mem64 $mem64
    ^^^^^^^^^^^
out/test/parse/expr/bad-memory-copy-differing-type.txt:71:5: error: type mismatch in memory.copy, expected [i32, i32, i32] but got [i64, i32, i32]
    memory.copy $mem32 $mem32
    ^^^^^^^^^^^
out/test/parse/expr/bad-memory-copy-differing-type.txt:76:5: error: type mismatch in memory.copy, expected [i32, i32, i32] but got [i32, i64, i32]
    memory.copy $mem32 $mem32
    ^^^^^^^^^^^
out/test/parse/expr/bad-memory-copy-differing-type.txt:81:5: error: type mismatch in memory.copy, expected [i32, i32, i32] but got [i32, i32, i64]
    memory.copy $mem32 $mem32
    ^^^^^^^^^^^
;;; STDERR ;;)
