mutagen
mutagen copied to clipboard
fails to parse multiple arithmetic operators without parentheses
10 #[mutate]
11 pub fn add_five(i: usize) -> usize {
12 i + 4 + 1
13 }
fails to cargo test with:
error: custom attribute panicked
--> src/test.rs:10:1
|
157 | #[mutate]
| ^^^^^^^^^
|
= help: message: expected expression
error: aborting due to previous error
If you change the plus to a minus, it produces instead
error[E0308]: mismatched types
--> src/test.rs:10:1
|
157 | #[mutate]
| ^^^^^^^^^ expected (), found usize
|
= note: expected type `()`
found type `usize`
error[E0308]: mismatched types
--> src/test.rs:10:1
|
157 | #[mutate]
| ^^^^^^^^^- help: try adding a semicolon: `;`
| |
| expected (), found usize
|
= note: expected type `()`
found type `usize`
error[E0600]: cannot apply unary operator `-` to type `usize`
--> src/test.rs:10:1
|
157 | #[mutate]
| ^^^^^^^^^ cannot apply unary operator `-`
|
= note: unsigned values cannot be negated
error: aborting due to 3 previous errors
With multiply as the second operation instead:
error[E0271]: type mismatch resolving `<i32 as mutagen::MulDiv>::Output == usize`
--> src/test.rs:10:1
|
157 | #[mutate]
| ^^^^^^^^^ expected i32, found usize
error: aborting due to previous error
this one can be fixed by putting parens around the #left $op_found #right
in the definition of fold_binary!
, although i'm honestly not sure why.