Skip to content

Commit

Permalink
Addressing more reviewer comments. This revamps the generation of err…
Browse files Browse the repository at this point in the history
…or messages, removing some older broken heuristics and trying to fix the problem of orientation of 'expected' vs 'found' at the core. Some context annotation 'from assignment context' not tries to clarify the error message if the typing error is for an lvalue, where the expected type is a _lower bound_ instead of an upper bound, which may leads to confusion for end users. The messages are now more systematic but perhaps a bit harder to understand, yet this is not trivial to fix and we have to iterate on this.
  • Loading branch information
wrwg committed Aug 31, 2023
1 parent d2b9d5d commit be9262c
Show file tree
Hide file tree
Showing 52 changed files with 527 additions and 499 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ error: expected `S` but found `M::S`
│ ^^^^

error: invalid call of `M::bar`: expected `M::S` but found `S` for argument 1
┌─ tests/checking/naming/generics_shadowing_invalid.move:9:9
┌─ tests/checking/naming/generics_shadowing_invalid.move:9:13
9 │ bar(s1);
^^^^^^^
^^

error: expected `S` but found `M::S`
┌─ tests/checking/naming/generics_shadowing_invalid.move:10:9
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@

Diagnostics:
error: expected `&u64` but found `integer`
┌─ tests/checking/typing/assign_unpack_references_invalid.move:9:13
error: expected `&u64` but found `integer` (from assignment or declaration context)
┌─ tests/checking/typing/assign_unpack_references_invalid.move:9:9
9 │ f = 0;
^
│ ^

error: expected `&M::S` but found `M::S`
error: expected `&M::S` but found `M::S` (from assignment or declaration context)
┌─ tests/checking/typing/assign_unpack_references_invalid.move:10:9
10 │ s2 = S { f: 0 }
│ ^^

error: expected `&mut u64` but found `integer`
┌─ tests/checking/typing/assign_unpack_references_invalid.move:17:13
error: expected `&mut u64` but found `integer` (from assignment or declaration context)
┌─ tests/checking/typing/assign_unpack_references_invalid.move:17:9
17 │ f = 0;
^
│ ^

error: expected `&mut M::S` but found `M::S`
error: expected `&mut M::S` but found `M::S` (from assignment or declaration context)
┌─ tests/checking/typing/assign_unpack_references_invalid.move:18:9
18 │ s2 = S { f: 0 }
│ ^^

error: mutability mismatch (&mut != &)
error: mutability mismatch (&mut != &) (from assignment or declaration context)
┌─ tests/checking/typing/assign_unpack_references_invalid.move:26:9
26 │ f = &0;
│ ^

error: mutability mismatch (&mut != &)
error: mutability mismatch (&mut != &) (from assignment or declaration context)
┌─ tests/checking/typing/assign_unpack_references_invalid.move:27:9
27 │ s2 = &S { f: 0 }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

Diagnostics:
error: tuples have different arity (0 != 3)
error: tuples have different arity (0 != 3) (from assignment or declaration context)
┌─ tests/checking/typing/assign_wrong_arity.move:7:9
7 │ x = (0, 1, 2);
│ ^

error: expected `()` but found `integer`
┌─ tests/checking/typing/assign_wrong_arity.move:8:14
error: expected `()` but found `integer` (from assignment or declaration context)
┌─ tests/checking/typing/assign_wrong_arity.move:8:9
8 │ () = 0;
^
^^

error: expected 4 item(s), found 3
┌─ tests/checking/typing/assign_wrong_arity.move:11:9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ error: expected `M::S` but found `M::R`
9 │ (S { g }, R { f }) = (R{ f: 0 }, R{ f: 1 });
│ ^^^^^^^

error: expected `()` but found `integer`
┌─ tests/checking/typing/assign_wrong_type.move:17:14
error: expected `()` but found `integer` (from assignment or declaration context)
┌─ tests/checking/typing/assign_wrong_type.move:17:9
17 │ () = 0;
^
^^

error: expected 4 item(s), found 3
┌─ tests/checking/typing/assign_wrong_type.move:18:9
Expand All @@ -30,25 +30,25 @@ error: expected 2 item(s), found 3
19 │ (x, b, R{f}) = (0, false);
│ ^^^^^^^^^^^^

error: expected `bool` but found `integer`
┌─ tests/checking/typing/assign_wrong_type.move:27:28
error: expected `bool` but found `integer` (from assignment or declaration context)
┌─ tests/checking/typing/assign_wrong_type.move:27:10
27 │ (x, b, R{f}, r) = (0, false, R{f: 0}, R{f: 0});
^
│ ^

error: expected `bool` but found `integer`
┌─ tests/checking/typing/assign_wrong_type.move:24:17
error: expected `integer` but found `bool` (from assignment or declaration context)
┌─ tests/checking/typing/assign_wrong_type.move:27:13
24let b = 0;
^
27(x, b, R{f}, r) = (0, false, R{f: 0}, R{f: 0});
│ ^

error: expected `address` but found `u64`
error: expected `address` but found `u64` (from assignment or declaration context)
┌─ tests/checking/typing/assign_wrong_type.move:27:18
27 │ (x, b, R{f}, r) = (0, false, R{f: 0}, R{f: 0});
│ ^

error: expected `M::S` but found `M::R`
error: expected `M::S` but found `M::R` (from assignment or declaration context)
┌─ tests/checking/typing/assign_wrong_type.move:27:22
27 │ (x, b, R{f}, r) = (0, false, R{f: 0}, R{f: 0});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,76 @@ error: invalid call of `+`: expected `integer` but found `bool` for argument 1
┌─ tests/checking/typing/binary_add_invalid.move:8:9
8 │ false + true;
│ ^^^^^^^^^^^^
│ ^^^^^

error: invalid call of `+`: expected `integer` but found `bool` for argument 2
┌─ tests/checking/typing/binary_add_invalid.move:9:9
┌─ tests/checking/typing/binary_add_invalid.move:9:13
9 │ 1 + false;
^^^^^^^^^
^^^^^

error: invalid call of `+`: expected `integer` but found `bool` for argument 1
┌─ tests/checking/typing/binary_add_invalid.move:10:9
10 │ false + 1;
│ ^^^^^^^^^
│ ^^^^^

error: invalid call of `+`: expected `integer` but found `address` for argument 1
┌─ tests/checking/typing/binary_add_invalid.move:11:9
11 │ @0x0 + @0x1;
│ ^^^^^^^^^^^
│ ^^^^

error: invalid call of `+`: expected `u8` but found `u128` for argument 2
┌─ tests/checking/typing/binary_add_invalid.move:12:9
┌─ tests/checking/typing/binary_add_invalid.move:12:20
12 │ (0: u8) + (1: u128);
^^^^^^^^^^^^^^^^^^^
^

error: invalid call of `+`: expected `integer` but found `M::R` for argument 1
┌─ tests/checking/typing/binary_add_invalid.move:13:9
13 │ r + r;
│ ^^^^^
│ ^

error: invalid call of `+`: expected `integer` but found `M::S` for argument 1
┌─ tests/checking/typing/binary_add_invalid.move:14:9
14 │ s + s;
│ ^^^^^
│ ^

error: invalid call of `+`: expected `integer` but found `bool` for argument 2
┌─ tests/checking/typing/binary_add_invalid.move:15:9
┌─ tests/checking/typing/binary_add_invalid.move:15:13
15 │ 1 + false + @0x0 + 0;
^^^^^^^^^
^^^^^

error: invalid call of `+`: expected `integer` but found `address` for argument 2
┌─ tests/checking/typing/binary_add_invalid.move:15:9
┌─ tests/checking/typing/binary_add_invalid.move:15:21
15 │ 1 + false + @0x0 + 0;
^^^^^^^^^^^^^^^^
^^^^

error: invalid call of `+`: expected `integer` but found `()` for argument 1
┌─ tests/checking/typing/binary_add_invalid.move:16:9
16 │ () + ();
│ ^^^^^^^
│ ^^

error: invalid call of `+`: expected `integer` but found `()` for argument 2
┌─ tests/checking/typing/binary_add_invalid.move:17:9
┌─ tests/checking/typing/binary_add_invalid.move:17:13
17 │ 1 + ();
^^^^^^
^^

error: invalid call of `+`: expected `integer` but found `(integer, integer)` for argument 1
┌─ tests/checking/typing/binary_add_invalid.move:18:9
18 │ (0, 1) + (0, 1, 2);
│ ^^^^^^^^^^^^^^^^^^
│ ^^^^^^

error: invalid call of `+`: expected `integer` but found `(integer, integer)` for argument 1
┌─ tests/checking/typing/binary_add_invalid.move:19:9
19 │ (1, 2) + (0, 1);
│ ^^^^^^^^^^^^^^^
│ ^^^^^^
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,46 @@ error: invalid call of `&&`: expected `bool` but found `address` for argument 1
┌─ tests/checking/typing/binary_and_invalid.move:11:9
11 │ @0x0 && @0x1;
│ ^^^^^^^^^^^^
│ ^^^^

error: invalid call of `&&`: expected `bool` but found `u8` for argument 1
┌─ tests/checking/typing/binary_and_invalid.move:12:9
┌─ tests/checking/typing/binary_and_invalid.move:12:10
12 │ (0: u8) && (1: u128);
^^^^^^^^^^^^^^^^^^^^
^

error: invalid call of `&&`: expected `bool` but found `M::R` for argument 1
┌─ tests/checking/typing/binary_and_invalid.move:13:9
13 │ r && r;
│ ^^^^^^
│ ^

error: invalid call of `&&`: expected `bool` but found `M::S` for argument 1
┌─ tests/checking/typing/binary_and_invalid.move:14:9
14 │ s && s;
│ ^^^^^^
│ ^

error: invalid call of `&&`: expected `bool` but found `()` for argument 1
┌─ tests/checking/typing/binary_and_invalid.move:15:9
15 │ () && ();
│ ^^^^^^^^
│ ^^

error: invalid call of `&&`: expected `bool` but found `()` for argument 2
┌─ tests/checking/typing/binary_and_invalid.move:16:9
┌─ tests/checking/typing/binary_and_invalid.move:16:17
16 │ true && ();
^^^^^^^^^^
^^

error: invalid call of `&&`: expected `bool` but found `(bool, bool)` for argument 1
┌─ tests/checking/typing/binary_and_invalid.move:17:9
17 │ (true, false) && (true, false, true);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ ^^^^^^^^^^^^^

error: invalid call of `&&`: expected `bool` but found `(bool, bool)` for argument 1
┌─ tests/checking/typing/binary_and_invalid.move:18:9
18 │ (true, true) && (false, false);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ ^^^^^^^^^^^^
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,76 @@ error: invalid call of `&`: expected `integer` but found `bool` for argument 1
┌─ tests/checking/typing/binary_bit_and_invalid.move:8:9
8 │ false & true;
│ ^^^^^^^^^^^^
│ ^^^^^

error: invalid call of `&`: expected `integer` but found `bool` for argument 2
┌─ tests/checking/typing/binary_bit_and_invalid.move:9:9
┌─ tests/checking/typing/binary_bit_and_invalid.move:9:13
9 │ 1 & false;
^^^^^^^^^
^^^^^

error: invalid call of `&`: expected `integer` but found `bool` for argument 1
┌─ tests/checking/typing/binary_bit_and_invalid.move:10:9
10 │ false & 1;
│ ^^^^^^^^^
│ ^^^^^

error: invalid call of `&`: expected `integer` but found `address` for argument 1
┌─ tests/checking/typing/binary_bit_and_invalid.move:11:9
11 │ @0x0 & @0x1;
│ ^^^^^^^^^^^
│ ^^^^

error: invalid call of `&`: expected `u8` but found `u128` for argument 2
┌─ tests/checking/typing/binary_bit_and_invalid.move:12:9
┌─ tests/checking/typing/binary_bit_and_invalid.move:12:20
12 │ (0: u8) & (1: u128);
^^^^^^^^^^^^^^^^^^^
^

error: invalid call of `&`: expected `integer` but found `M::R` for argument 1
┌─ tests/checking/typing/binary_bit_and_invalid.move:13:9
13 │ r & r;
│ ^^^^^
│ ^

error: invalid call of `&`: expected `integer` but found `M::S` for argument 1
┌─ tests/checking/typing/binary_bit_and_invalid.move:14:9
14 │ s & s;
│ ^^^^^
│ ^

error: invalid call of `&`: expected `integer` but found `bool` for argument 2
┌─ tests/checking/typing/binary_bit_and_invalid.move:15:9
┌─ tests/checking/typing/binary_bit_and_invalid.move:15:13
15 │ 1 & false & @0x0 & 0;
^^^^^^^^^
^^^^^

error: invalid call of `&`: expected `integer` but found `address` for argument 2
┌─ tests/checking/typing/binary_bit_and_invalid.move:15:9
┌─ tests/checking/typing/binary_bit_and_invalid.move:15:21
15 │ 1 & false & @0x0 & 0;
^^^^^^^^^^^^^^^^
^^^^

error: invalid call of `&`: expected `integer` but found `()` for argument 1
┌─ tests/checking/typing/binary_bit_and_invalid.move:16:9
16 │ () & ();
│ ^^^^^^^
│ ^^

error: invalid call of `&`: expected `integer` but found `()` for argument 2
┌─ tests/checking/typing/binary_bit_and_invalid.move:17:9
┌─ tests/checking/typing/binary_bit_and_invalid.move:17:13
17 │ 1 & ();
^^^^^^
^^

error: invalid call of `&`: expected `integer` but found `(integer, integer)` for argument 1
┌─ tests/checking/typing/binary_bit_and_invalid.move:18:9
18 │ (0, 1) & (0, 1, 2);
│ ^^^^^^^^^^^^^^^^^^
│ ^^^^^^

error: invalid call of `&`: expected `integer` but found `(integer, integer)` for argument 1
┌─ tests/checking/typing/binary_bit_and_invalid.move:19:9
19 │ (1, 2) & (0, 1);
│ ^^^^^^^^^^^^^^^
│ ^^^^^^
Loading

0 comments on commit be9262c

Please sign in to comment.