Skip to content

Commit

Permalink
testing wrong index types
Browse files Browse the repository at this point in the history
  • Loading branch information
xunilrj committed Jul 26, 2024
1 parent c2a7e00 commit 8c17162
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,20 @@ fn main() {
__slice(0, 0, 0);

// Wrong start index
__slice(0, "", 0);
__slice(a, "", 0);

// Wrong end index
__slice(0, 0, "");
__slice(a, 0, "");

let a: [u64; 5] = [1, 2, 3, 4, 5];
let s: &__slice[u64] = __slice(LOCAL_ARRAY, 0, 5);

// Wrong first argument
__elem_at(0, 0);

// Wrong index type
__elem_at(a, "");

// Wrong index type
__elem_at(s, "");
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,28 @@ category = "fail"
# check: __slice(0, 0, 0)
# nextln: $()Unsupported argument type to intrinsic "slice"

# check: __slice(0, "", 0)
# check: __slice(a, "", 0)
# nextln: $()Mismatched types
# nextln: $()expected: u64
# nextln: $()found: str

# check: __slice(0, 0, "")
# check: __slice(a, 0, "")
# nextln: $()Mismatched types
# nextln: $()expected: u64
# nextln: $()found: str
#
# check: __elem_at(0, 0);
# nextln: $()Unsupported argument type to intrinsic "elem_at"

# check: __elem_at(a, "");
# nextln: $()Mismatched types.
# nextln: $()expected: u64
# nextln: $()found: str.

# check: __elem_at(s, "");
# nextln: $()Mismatched types.
# nextln: $()expected: u64
# nextln: $()found: str.

# check: &__slice[u64] = __slice(GLOBAL_ARRAY, 0, 5)
# nextln: $()slices or types containing slices on `const` are not allowed
Expand Down

0 comments on commit 8c17162

Please sign in to comment.