From 2f351f3a84037902740f05085584ad60e388c24b Mon Sep 17 00:00:00 2001
From: YiYing He <yiying@secondstate.io>
Date: Sat, 2 Dec 2023 01:37:00 +0800
Subject: [PATCH] [test] Unify the error message.

1. "array is immutable" for trying to assign values into an immutable
   array in validation.
2. "out of bounds array access" for trying to access out of bounds array
   in execution.

Signed-off-by: YiYing He <yiying@secondstate.io>
---
 interpreter/valid/valid.ml   |  2 +-
 test/core/gc/array.wast      | 16 ++++++++--------
 test/core/gc/array_copy.wast |  2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/interpreter/valid/valid.ml b/interpreter/valid/valid.ml
index e14fc6d36..f076e42b4 100644
--- a/interpreter/valid/valid.ml
+++ b/interpreter/valid/valid.ml
@@ -758,7 +758,7 @@ let rec check_instr (c : context) (e : instr) (s : infer_result_type) : infer_in
   | ArrayCopy (x, y) ->
     let ArrayT (FieldT (mutd, std)) = array_type c x in
     let ArrayT (FieldT (_muts, sts)) = array_type c y in
-    require (mutd = Var) e.at "destination array is immutable";
+    require (mutd = Var) e.at "array is immutable";
     require (match_storage_type c.types sts std) e.at "array types do not match";
     [RefT (Null, DefHT (type_ c x)); NumT I32T; RefT (Null, DefHT (type_ c y)); NumT I32T; NumT I32T] --> [], []
 
diff --git a/test/core/gc/array.wast b/test/core/gc/array.wast
index 0da7e8432..f5888cb2d 100644
--- a/test/core/gc/array.wast
+++ b/test/core/gc/array.wast
@@ -100,8 +100,8 @@
 (assert_return (invoke "set_get" (i32.const 1) (f32.const 7)) (f32.const 7))
 (assert_return (invoke "len") (i32.const 3))
 
-(assert_trap (invoke "get" (i32.const 10)) "out of bounds")
-(assert_trap (invoke "set_get" (i32.const 10) (f32.const 7)) "out of bounds")
+(assert_trap (invoke "get" (i32.const 10)) "out of bounds array access")
+(assert_trap (invoke "set_get" (i32.const 10) (f32.const 7)) "out of bounds array access")
 
 (module
   (type $vec (array f32))
@@ -145,8 +145,8 @@
 (assert_return (invoke "set_get" (i32.const 1) (f32.const 7)) (f32.const 7))
 (assert_return (invoke "len") (i32.const 2))
 
-(assert_trap (invoke "get" (i32.const 10)) "out of bounds")
-(assert_trap (invoke "set_get" (i32.const 10) (f32.const 7)) "out of bounds")
+(assert_trap (invoke "get" (i32.const 10)) "out of bounds array access")
+(assert_trap (invoke "set_get" (i32.const 10) (f32.const 7)) "out of bounds array access")
 
 (module
   (type $vec (array i8))
@@ -190,8 +190,8 @@
 (assert_return (invoke "set_get" (i32.const 1) (i32.const 7)) (i32.const 7))
 (assert_return (invoke "len") (i32.const 3))
 
-(assert_trap (invoke "get" (i32.const 10)) "out of bounds")
-(assert_trap (invoke "set_get" (i32.const 10) (i32.const 7)) "out of bounds")
+(assert_trap (invoke "get" (i32.const 10)) "out of bounds array access")
+(assert_trap (invoke "set_get" (i32.const 10) (i32.const 7)) "out of bounds array access")
 
 (module
   (type $bvec (array i8))
@@ -249,8 +249,8 @@
 (assert_return (invoke "set_get" (i32.const 0) (i32.const 1) (i32.const 1)) (i32.const 2))
 (assert_return (invoke "len") (i32.const 2))
 
-(assert_trap (invoke "get" (i32.const 10) (i32.const 0)) "out of bounds")
-(assert_trap (invoke "set_get" (i32.const 10) (i32.const 0) (i32.const 0)) "out of bounds")
+(assert_trap (invoke "get" (i32.const 10) (i32.const 0)) "out of bounds array access")
+(assert_trap (invoke "set_get" (i32.const 10) (i32.const 0) (i32.const 0)) "out of bounds array access")
 
 (assert_invalid
   (module
diff --git a/test/core/gc/array_copy.wast b/test/core/gc/array_copy.wast
index 06090cb53..d1caf1264 100644
--- a/test/core/gc/array_copy.wast
+++ b/test/core/gc/array_copy.wast
@@ -11,7 +11,7 @@
       (array.copy $a $b (local.get $1) (i32.const 0) (local.get $2) (i32.const 0) (i32.const 0))
     )
   )
-  "destination array is immutable"
+  "array is immutable"
 )
 
 (assert_invalid