Skip to content

[Bug] Incorrect error location in Move tests when there is an arithmetic error #17188

@vineethk

Description

@vineethk

🐛 Bug

Consider the following move program:

module 0xc0ffee::m {
    #[test]
    public fun demonstrate_conversions() {
        let x = 0;
        assert!(x == 0, 700);

        let big_number: u64 = 1000;
        let small_number: u8 = (big_number as u8);
        assert!(small_number == 255, 703);
    }
}

When we run aptos move test, we get the following error:

│ error[E11001]: test failure
│   ┌─ /Users/vineeth/Code/review/testing/checker/sources/main.move:5:9
│   │
│ 3 │     public fun demonstrate_conversions() {
│   │                ----------------------- In this function in 0xc0ffee::m
│ 4 │         let x = 0;
│ 5 │         assert!(x == 0, 700);
│   │         ^^^^^^ Test was not expected to error, but it gave an arithmetic error with error message: "Cannot cast u64(1000) to u8". Error originating in the module 0000000000000000000000000000000000000000000000000000000000c0ffee::m rooted here

Clearly, the location pinpointed for the error is incorrect.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions